<template>
	<view class="body">
		<!-- 运输信息 -->
		<view class="" v-show="userType=='1'">
			
		
		<view class="ys_msg" v-if="userType=='1'">
			<view class="item_top">
				<view class="view_pai"><text class="text_pai">运输信息</text></view>
				<view class="line"></view>
			</view>
			<view class="ys_item">
				<view class="text_item" span="2">
					<text class="lable" @click="cph()">车牌号</text>
					<!-- </picker> -->
					<text class="value">{{ysMsgMap.vehCode==""?"无":ysMsgMap.vehCode}}</text>
				</view>
				<view class="text_item" span="2">
					<text class="lable" @click="gcph()">挂车牌号</text>
					<!-- </picker> -->

					<text class="value">{{ysMsgMap.trailerVehCode==""?"无":ysMsgMap.trailerVehCode}}</text>
				</view>
			</view>
			<view class="ys_item" style="border: none;">
				<view class="text_item" span="2">
					<text class="lable" @click="jsy()">驾驶员</text>
					<!-- </picker> -->
					<text class="value">{{ysMsgMap.driverName==""?"无":ysMsgMap.driverName}}</text>

				</view>
				<view class="text_item" span="2">
					<text class="lable" @click="yyy()">押运员</text>
					<!-- </picker> -->
					<text class="value">{{ysMsgMap.escortName==""?"无":ysMsgMap.escortName}}</text>
				</view>
			</view>


		</view>

		<view class="tcwf">
			<view class="item_top">
				<view class="view_pai"><text class="text_pai">任务类型</text></view>
				<view class="line"></view>
			</view>
			<view style="width: 36%;">
				<checkbox class="checkbox" :checked="isCity" color="#FFCC33" style="transform:scale(0.7)"
					@click="isCityClick()" />
				是否同城配送
			</view>
			<view style="width: 37%;">
				<checkbox class="checkbox" :checked="isWeiF" color="#FFCC33" style="transform:scale(0.7)"
					@click="isWeiFClick()" />
				是否医废危废
			</view>
		</view>
		<view class="tcwf" style="height: 68rpx;">
			<view class="item_top">
				<view class="view_pai"><text class="text_pai">运输类型</text></view>
				<view class="line"></view>
			</view>
			<view class="info-item">
				<!-- 	<text class="text">包装规格</text> -->
				<picker mode="selector" :range="yslxlist" range-key="packingSpec" @change="yslxChange(index,$event)">
					<input class="input" placeholder="请先选择运输类型" type="text" v-model="yslxobj.label" disabled />
				</picker>
			</view>
		</view>
		<view style="height: 23rpx;background: #f2f2f2;width: 100%;">

		</view>
		<view class="box" v-for="(ele,inx) in hwinfohz" :key="inx">
			<view class="zhinfo item_top">
				<!-- 装货信息{{inx==1?"":index+1}}
				 -->
				<view class="view_pai">
					<text class="text_pai">装货信息{{hwinfohz.length==1?"":inx+1}}</text>
					<image class="delect" v-if=" hwinfohz.length!=1"
						src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png" @click="delectZh(inx)"></image>
				</view>
			</view>

			<view>
				<!-- 货物信息 -->
				<view v-for="(item,index) in ele.hw_map.ownerGoodsName" :key="index">
					<view class="hw_msg">
						<view class="item_top">
							<view class="view_pai">
								<text class="text_pai">货物信息{{ele.hw_map.ownerGoodsName.length==1?"":index+1}}</text>
								<image class="delect" v-if="ele.hw_map.ownerGoodsName.length!=1"
									src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png" @click="delectHw(index,inx)">
								</image>
							</view>
							<view class="line"></view>
						</view>
						<view class="info-item">
							<text class="text" style="color: #FFD14A;" @click="hwmc(index,'',inx)">货物名称</text>
							<input class="input" disabled type="text" @click="hwmc(index,'',inx)"
								v-model="ele.hw_map.ownerGoodsAlias[index]" @input="(e)=>inputSearch(e,index,'5',inx)"
								@confirm="doSearch(index,ele.hw_map.ownerGoodsAlias[index],'5',inx)"
								placeholder="请输入货物名称" />
						</view>
						<view class="info-item">
							<text class="text">包装规格</text>
							<picker mode="selector" :range="ele.hw_map.hw_ggList[index]" range-key="packingSpec"
								:disabled=isbzgg @change="hwggChange(index,$event,inx)">
								<input class="input"
									:placeholder="ele.hw_map.ownerGoodsAlias[index]?'请先配置包装规格':'请先输入包装规格'" type="text"
									v-model="ele.hw_map.hw_gg[index]" disabled />
							</picker>
						</view>
						<view class="info-item">
							<text class="text">项别类别</text>
							<text class="text"
								style="margin-left: 20rpx;">{{ele.hw_map.hw_type[index]==""?"无":ele.hw_map.hw_type[index]}}</text>
						</view>
						<view class="info-item">
							<text class="text">数量</text>
							<input class="input" type="digit" @blur="initHwNum(index,inx)"
								v-model="ele.hw_map.hw_num[index]" placeholder="请输入数量" />
							<text class="text_dw"
								@click="clickDw(index,inx)">{{ele.hw_map.hw_dw[index]==""?"选择货物单位":ele.hw_map.hw_dw[index]}}</text>

						</view>
						<view class="info-item">
							<text class="text">重量</text>
							<input class="input" type="digit" v-model="ele.hw_map.hw_zl[index]" placeholder="请输入重量" />
							<text>吨</text>
						</view>
						<view class="hw_btn" v-if="ele.hw_map.ownerGoodsName.length-1==index" @click="addHw(inx)">
							<text>+新增运输货物</text>
						</view>
					</view>
				</view>
			</view>

			<!-- 托运方 -->
			<view class="hw_msg" style="padding-bottom: 0rpx;">
				<view class="item_top">
					<view class="view_pai">
						<text class="text_pai">托运方</text>
					</view>
					<view class="line"></view>
				</view>
				<view class="info-item">
					<text class="text" style="color: #FFD14A;" @click="tymc('',inx)">名称</text>
					<input class="input" type="text" v-model="ele.ty_map.ty_name"
						@input="(e)=>inputSearch(e,'','6',inx)" @confirm="doSearch('',ele.ty_map.ty_name,'6',inx)"
						placeholder="请输入托运方名称" />
				</view>
				<view class="info-item" style="border: none;">
					<text class="text">联系电话</text>
					<input class="input" type="text" v-model="ele.ty_map.ty_phoneNum" placeholder="请输入联系电话" />
				</view>
				<view class="info-item" style="border: none;">
					<text class="text">统一社会信用代码</text>
					<input class="input" type="text" v-model="ele.ty_map.ty_tyshxy" placeholder="请输入统一社会信用代码" />
				</view>
				<view class="info-item">
					<text class="text">所属合同</text>
					<picker mode="selector" :range="ele.ty_map.hwtyht" range-key="packingSpec"
						@change="hwtyhtChange(index,$event,inx,1)">
						<input class="input" placeholder="请选择所属合同" type="text" v-model="ele.ty_map.ty_ssht" disabled />
					</picker>
				</view>

			</view>

			<view>
				<!-- 装货方 -->
				<view v-for="(item,index) in ele.zh_map.zh_name" :key="index">
					<view class="zh_msg" :class="{isPadding:zhshow && ele.zh_map.zh_name.length-1==index}">
						<view class="item_top">
							<view class="view_pai">
								<text class="text_pai">装货方{{ele.zh_map.zh_name.length==1?"":index+1}}</text>
								<!-- <image class="delect" v-if=" zhshow && ele.zh_map.zh_name.length!=1" src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png"
								@click="delectZh(index)"></image> -->
							</view>
							<view class="line"></view>
						</view>
						<view class="info-item">
							<text class="text" style="color: #FFD14A;" @click="zhmc(index,'',inx)">名称</text>
							<input class="inputDq" type="text" v-model="ele.zh_map.zh_name[index]"
								@input="(e)=>inputSearch(e,index,'7',inx)"
								@confirm="doSearch(index,ele.zh_map.zh_name[index],'7',inx)" placeholder="请输入装货方名称" />
						</view>
						<view class="info-item">
							<text class="text">联系电话</text>
							<input class="input" type="text" v-model="ele.zh_map.zh_phoneNum[index]"
								placeholder="请输入联系电话" />
						</view>
						<view class="info-item" style="border: none;">
							<text class="text">统一社会信用代码</text>
							<input class="input" type="text" v-model="ele.zh_map.zh_tyshxy" placeholder="请输入统一社会信用代码" />
						</view>
						<view class="info-item">
							<text class="text">所在地区</text>
							<!-- <input class="input" type="text" v-model="zh_map.zh_dq[index]" placeholder="请输入联系电话" /> -->
							<select-region class="inputDq" :localdata="regionData"
								@change="(text)=>changeAdrZ(index,text,inx)" v-model="ele.zh_map.zh_dqCode[index]"
								placeholder="请选择所在地区"></select-region>
						</view>
						<view class="info-item">
							<text class="text">详细地址</text>
							<textarea :auto-height='true' class="input" v-model="ele.zh_map.zh_address[index]"
								placeholder="请输入装货方详细地址" />
						</view>
						<view class="hw_btn" v-if="zhshow && hwinfohz.length-1==inx" @click="addZh()">
							<text>+新增装货方</text>
						</view>
					</view>
				</view>
			</view>
			<view>
			</view>
		</view>
		</view>
		<view class="">
			
		
		<!-- <view style="height: 23rpx;background: #f2f2f2;width: 100%;">

		</view> -->
		<!-- 收货方 -->
		<view v-for="(item,index) in xhinfohz" :key="index">
			<view class="shinfo item_top">
				<!-- 装货信息{{inx==1?"":index+1}}
					 -->
				<view class="view_pai">
					<text class="text_pai">卸货信息{{xhinfohz.length==1?"":index+1}}</text>
					<image class="delect" v-if="xhinfohz.length!=1"
						src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png" @click="delectSh(index)"></image>
				</view>
			</view>
			<view class="zh_msg" :class="{isPadding:shshow && item.sh_map.sh_name.length-1==index}">
				<view class="item_top">
					<view class="view_pai">
						<text class="text_pai">卸货方</text>
						<!-- <image class="delect" v-if="sh_map.sh_name.length!=1" src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png"
								@click="delectSh(index)"></image> -->
					</view>
					<view class="line"></view>
				</view>
				<view class="info-item">
					<text class="text" style="color: #FFD14A;" @click="shmc(index,'')">名称</text>
					<!-- </picker> -->
					<input class="input" type="text" v-model="item.sh_map.sh_name[0]"
						@input="(e)=>inputSearch(e,index,'8')" @confirm="doSearch(index,item.sh_map.sh_name[0],'8')"
						placeholder="请输入卸货方名称" />
				</view>
				<view class="info-item">
					<text class="text">联系电话</text>
					<input class="input" type="text" v-model="item.sh_map.sh_phoneNum[0]" placeholder="请输入联系电话" />
				</view>
				<view class="info-item" style="border: none;">
					<text class="text">统一社会信用代码</text>
					<input class="input" type="text" v-model="item.sh_map.sh_tyshxy" placeholder="请输入统一社会信用代码" />
				</view>
				<view class="info-item">
					<text class="text">所在地区</text>
					<!-- <input class="input" type="text" v-model="sh_map.sh_dq[index]" placeholder="请输入联系电话" /> -->

					<select-region class="inputDq" :localdata="regionData" @change="(text)=>changeAdrS(index,text)"
						v-model="item.sh_map.sh_dqCode[0]" placeholder="请选择所在地区"></select-region>
				</view>
				<view class="info-item">
					<!-- <text class="text">详细地址</text> -->
					<text class="text" style="color: #FFD14A;" @click="shdz(index,'')">详细地址</text>
					<textarea class="input" :auto-height='true' v-model="item.sh_map.sh_address[0]" @input="(e)=>inputSearch(e,index,'12')" @confirm="doSearch(index,item.sh_map.sh_address[0],'12')"
						placeholder="请输入收货方详细地址" />
				</view>
				<view class="" v-for="(el,m) in item.sh_map.hw_num" :key="m">
					<view class="item_top">
						<view class="view_pai">
							<text class="text_pai">卸载货物信息{{item.sh_map.hw_num.length==1?"":m+1}}</text>
							<image class="delect" v-if="item.sh_map.hw_num.length!=1"
								src="https://whfw.ahjtzf.cn:4330/wyad_img/delect.png" @click="delectHwxh(m,index)">
							</image>
						</view>
						<view class="line"></view>
					</view>
				
				<view class="info-item" style="align-items: center">
					<text class="text">卸载货物信息</text>
					<ld-select style='width: 70%;' :multiple="false" :list="optionsxh" label-key="label"
						value-key="value" placeholder="请选择卸载货物信息" @confirm="selectChange(val,index)"
						v-model="item.sh_map.valuexh[m]"></ld-select>
				</view>
				<view class="info-item">
					<text class="text">数量</text>
					<input class="input" type="digit"
						v-model="item.sh_map.hw_num[m]" placeholder="请输入数量" />
					<text class="text_dw"
						>{{item.sh_map.hw_dw[m]}}</text>
						<!-- @click="clickDws(index,m)" -->
				
				</view>
				<view class="info-item">
					<text class="text">重量</text>
					<input class="input" type="digit" v-model="item.sh_map.hw_zl[m]" placeholder="请输入重量" />
					<text>吨</text>
				</view>
				<view class="hw_btn" v-if="item.sh_map.hw_num.length-1==m" @click="addHwxh(index)">
					<text>+新增卸载货物信息</text>
				</view>
				</view>
			
				<view class="hw_btn" v-if="shshow && xhinfohz.length-1==index" @click="addSh()">
					<text>+新增卸货方</text>
				</view>
			</view>
		</view>
       </view>
		<!-- <view style="height: 23rpx;background: #f2f2f2;width: 100%;">

		</view> -->
		<view >
			
		
		<!-- 途径信息 -->
		<view class="hw_msg" style="padding-bottom: 0rpx;">
			<view class="item_top">
				<view class="view_pai">
					<text class="text_pai">装卸货时间</text>
				</view>
				<view class="line"></view>
			</view>
			<view class="info-item">
				<text class="text">装货日期</text>
				<uni-datetime-picker class="date-select" type="date" :end="way_map.endTime" placeholder="请选择装货日期"
					v-model="way_map.startTime" />
			</view>
			<view class="info-item">
				<text class="text">卸货日期</text>
				<uni-datetime-picker class="date-select" type="date" :start="way_map.startTime" placeholder="请选择卸货日期" v-model="way_map.endTime" />
			</view>
			<view style="height: 23rpx;background: #f2f2f2;width: 100%;">

			</view>
			<view class="item_top">
				<view class="view_pai">
					<text class="text_pai">线路信息</text>
				</view>
				<view class="line"></view>
			</view>
			<view class="info-item">

				<text class="text">途径路线</text>
				<input class="inputDq" type="text" @input="(e)=>inputSearch(e,'','9')"
					@confirm="doSearch('',way_map.route,'9')" v-model="way_map.route" placeholder="请输入途径路线" />
			</view>
			<view class="info-item" style="border: none;">
				<text class="text">线路里程</text>
				<input class="input" type="digit" v-model="way_map.mileage" placeholder="请输入线路里程" />
				<text class="text">千米</text>
			</view>
			<view class="info-item" style="align-items: center">
				<text class="text">途径省份</text>
				<ld-select style='width: 75%;' :multiple="true" :list="optionsxl" label-key="label" value-key="value"
					placeholder="请选择途径省份" @confirm="selectChangecode" v-model="way_map.valuexl"></ld-select>

			</view>

		</view>
        </view>

<!-- <view class="add-btns" style="margin-top: 40rpx;">
			<view class="btn-cancel" @click="syb(tabsshow)">
				<text>上一步</text>
			</view>
			<view class="btn-submit"  v-if="tabsshow != 3" @click="xyb(tabsshow)">
				<text>下一步</text>
			</view>
			<view v-if="tabsshow == 3" class="btn-submit" @click="confirm()">
				<text>确 认</text>
			</view>
		</view> -->
		<view class="add-btns">
			<view class="btn-cancel" @click="cancal()">
				<text>取 消</text>
			</view>
			<view class="btn-submit" @click="confirm()">
				<text>确 认</text>
			</view>
		</view>
		<select-task ref="child1" @change="vehCodeChange"></select-task>
		<select-task ref="child2" @change="gvehCodeChange"></select-task>
		<select-task ref="child3" @change="jsyPersonChange"></select-task>
		<select-task ref="child4" @change="yyyPersonChange"></select-task>
		<!-- 货物名称-不分页 -->
		<select-task ref="goodsName1" @change="hwNameListChange"></select-task>
		<!-- 货物名称-分页 -->
		<selectTaskFy ref="goodsName2" @change="hwNameListChange" />
		<!-- 货物单位 -->
		<select-task ref="child5" @change="selectDw"></select-task>
		<select-task ref="child10" @change="selectDws"></select-task>
		<!-- 托运方 -->
		<selectTaskFy ref="child6" @change="tuoChange" />
		<!-- 装货方 -->
		<selectTaskFy ref="child7" @change="zhChange" />
		<!-- 收货方 -->
		<selectTaskFy ref="child8" @change="shChange" />
		<selectTaskFy ref="child12" @change="shdzChange" />
		<select-task ref="child9" @change="selectLine"></select-task>
		<modal-confirm :data="confirmData" :visible.sync="showDialog" @confirm="okJc" @cancel="cancelJc">
		</modal-confirm>
		<modal-confirm :data="qyMsgData" :visible.sync="isVisibleDialog" @confirm="okQy" @cancel="cancelQy">
		</modal-confirm>
	</view>
</template>

<script>
	import modalConfirm from '@/components/tool_task/show-log.vue';
	// import func from "@/common/util.js";
	// import store from "@/store/index";
	import selectTask from '@/components/tool-select/select-task.vue';
	import selectTaskFy from '@/components/tool-select/select-task-fy.vue';
	import selectRegion from '@/components/tool-select/select-region';
	import ldSelect from '@/components/ld-select/ld-select.vue'
	import {
		dateFormat
	} from '@/common/util.js';
	export default {
		components: {
			selectTask,
			selectTaskFy,
			selectRegion,
			modalConfirm,
			ldSelect
		},
		data() {
			return {
				tabsshow:1,
				isbzgg: true,
				isSubmitCreate: '0',
				//任务id
				taskId: "",
				//taskname
				goodsInfo: "",
				//驾押创建任务成功后 是否显示弹窗
				showDialog: false,
				//企业人员创建任务成功后 是否显示弹窗
				isVisibleDialog: false,
				confirmData: {
					title: '提示信息',
					content: "任务创建成功,是否进行出车前检查?"
				},

				qyMsgData: {
					title: '提示信息',
					content: "任务创建成功，是否进行车辆调度?"
				},
				//所在地区组件字段
				regionData: [],
				//无用字段 改变值监听 进行事件
				lisenter: [],
				//经纬度集合
				locationList: [],

				//装货所在地区 收获所在地区总和
				sumdqList: [],
				//上给页面传过来的参数
				options: {},
				//驾押运输信息map
				ysMsgMap: {
					vehId: "",
					vehCode: "",
					vehColor: "",
					trailerVehId: "",
					trailerVehCode: "",
					mgrArea: "",
					driverName: "",
					driverIdNumber: "",
					driverTel: "",
					driverEmpInfoId: "",
					escortName: "",
					escortIdNumber: "",
					escortTel: "",
					escortEmpInfoId: ""
				},
				userType: "",

				//驾驶员
				jsyPerson: {
					fullName: '', //驾驶员
					empInfoId: '', //驾驶员id
					mobilePhone: '' //驾驶员电话
				},
				//押运员
				yyyPerson: {
					fullName: '', //押运员
					empInfoId: '', //押运员id
					mobilePhone: '' //押运员电话
				},
				//途径map
				way_map: {
					mileage: "", //线路里程
					route: "", //路线
					lineId: "", //路线id
					startTime: '',
					endTime: '',
					valuexl: []
					// startTime:dateFormat(new Date(),'YYYY-mm-dd'),
					// endTime: dateFormat(new Date(),'YYYY-mm-dd'),
				},
				// 装货汇总
				hwinfohz: [{
					//托运方map
					ty_map: {
						ty_name: "", //托运方名称
						ty_phoneNum: "", //托运方联系电话
						custId: "", //托运方id
						ty_tyshxy: '',
						ty_ssht: '',
						ty_sshtid: '', //所属合同id
						hwtyht: []
					},
					//货物信息集合
					hw_map: {
						ownerGoodsName: [""], //货物名称
						hw_gg: [""], //包装规格
						hw_type: [""], //项目类别
						hw_num: [""], //货物数量
						hw_zl: [""], //货物重量
						hw_dw: [""], //单位
						hw_category: [""], //类别
						ownerGoodsId: [""], //企业常用危险货物包装ID
						hw_ggList: [
							[]
						], //包装规格集合
						category: [""], //类别
						termOther: [""], //项别
						ownerGoodsPkg: [""], ////企业常用危险货物包装ID
						unCode: [""], //联合国编号
						ownerGoodsAlias: [""], //正式运输名称
						taskGoodsId:''
					},
					//装货方
					zh_map: {
						zh_name: [""], //名称
						zh_phoneNum: [""], //联系电话
						zh_dq: [""], //所在地区
						zh_address: [""], //详细地址
						zh_dqCode: [""], //所在地区code
						zh_dqLocation: [""], //所在地区经纬度
						zh_location: [""], //装货方经纬度
						zh_corpCustId: [""], //装货公司客户ID
						zh_contactsName: [""], //装货联系人名称
						zh_custAddrId: [""], //装货客户地址ID
						zh_tyshxy: ''
					},
				}],


				// 卸货汇总
				xhinfohz: [{
						//收货方
						sh_map: {
							sh_tyshxy: '',
							sh_name: [""], //名称
							sh_phoneNum: [""], //联系电话
							sh_dq: [""], //所在地区
							sh_address: [""], //详细地址
							sh_dqCode: [""], //所在地区code
							sh_dqLocation: [""], //所在地区经纬度
							sh_location: [""], //收获方经纬度
							sh_corpCustId: [""], //收货公司客户ID                                        
							sh_contactsName: [""], //收货联系人名称  
							sh_custAddrId: [""], ////装货客户地址ID	
							// optionsxh:[],
							hw_num: [""], //货物数量
							hw_zl: [""], //货物重量
							hw_dw: [""], //单位
							valuexh: [],
							waybillNo:''

						},
					}


				],

				//是否同城
				isCity: false,
				//是否医废
				isWeiF: false,
				select: {
					dw: [{
							"value": "1",
							"text": "件"
						}, {
							"value": "2",
							"text": "升"
						}, {
							"value": "3",
							"text": "桶"
						}, {
							"value": "4",
							"text": "箱"
						}, {
							"value": "5",
							"text": "发"
						}, {
							"value": "6",
							"text": "米"
						}, {
							"value": "7",
							"text": "罐"
						},
						{
							"value": "8",
							"text": "瓶"
						},
						{
							"value": "9",
							"text": "袋"
						},
						{
							"value": "10",
							"text": "立方米"
						}

					],
					reason: [{
						"value": "1",
						"text": "车辆维修"
					}, {
						"value": "2",
						"text": "普通运输"
					}, {
						"value": "3",
						"text": "车辆年检"
					}, {
						"value": "4",
						"text": "罐体检验"
					}, {
						"value": "5",
						"text": "车辆保养"
					}, {
						"value": "6",
						"text": "非民用运输"
					}],
				},
				info: {
					reason: "", //包装规格
				},
				vehGoodsName: false,
				yslxlist: [{
						value: '1',
						packingSpec: '一装一卸'
					},
					{
						value: '2',
						packingSpec: '一装多卸'
					},
					{
						value: '3',
						packingSpec: '多装一卸'
					},
					{
						value: '4',
						packingSpec: '多装多卸'
					}
				],
				yslxobj: {

					value: '',
					label: ''

				},
				zhshow: false,
				shshow: false,
				hwbflist: [],
				// hwtyht:[]
				optionsxh: [ //下拉的数据

				],
				value2: [], //多选回显的数组
				optionsxl: [],
				zhdzxz:[]
			};
		},
		watch: {
			lisenter(newQuestion, oldQuestion) {
				setTimeout(() => {
					if (this.xhinfohz[this.xhinfohz.length-1].sh_map.sh_dqLocation[0] != "" && this.hwinfohz[0].zh_map.zh_dqLocation[
						0] != "") {
						this.sumdqList = this.hwinfohz[0].zh_map.zh_dqLocation.concat(this.xhinfohz[this.xhinfohz.length-1].sh_map
							.sh_dqLocation)
						//这显示途径路线
						// let arr = []
						// this.getAreaCode(this.hwinfohz[0].zh_map.zh_dqCode)
						let a = this.getSelectPath(this.hwinfohz[0].zh_map.zh_dqCode[0])
						let b =this.getSelectPath(this.xhinfohz[this.xhinfohz.length-1].sh_map.sh_dqCode[0])
						this.way_map.route =this.getAreaCode(a)+'--'+this.getAreaCode(b)
						// console.log(a,33,b)
						// this.way_map.route = this.hwinfohz[0].zh_map.zh_dq.concat(this.xhinfohz[0].sh_map.sh_dq)
							// .join('--')
						if (this.xhinfohz[0].sh_map.sh_dqLocation.length == 1 && this.hwinfohz[0].zh_map
							.zh_dqLocation.length == 1) {
							this.getDic(this.sumdqList[0], this.sumdqList[1], "")
						} else {
							this.getDic(this.sumdqList[0], this.sumdqList[this.sumdqList.length - 1], this
								.sumdqList)
						}
						this.getsfcode()
					}
					
				}, 1000);
			},
			"ysMsgMap.vehCode"() {
				// console.log(this.ysMsgMap);
				this.vehGoodsName = false;
				if (!this.ysMsgMap.vehId) {
					return;
				}
				let params = {
					vehId: this.ysMsgMap.vehId
				};
				this.$api.getVehGoodsName(params).then(res => {
					const resData = res.data.data.records;
					if (resData.length) {
						this.vehGoodsName = true;
						const firstItem = resData[0];
						this.getGoodsInfo(firstItem.goodsId)
							.then(item => {
								// console.log(item);
								// 重置货物信息
								var ggFirst = item.list[0];
								res.item = item;
								this.hwNameListChange(res)
								// this.hwinfohz[0].hw_map = {
								// 	hw_num: [""], //货物数量
								// 	hw_zl: [""], //货物重量
								// 	hw_dw: [""], //单位
								// 	ownerGoodsPkg: [""], ////企业常用危险货物包装ID
								// 	ownerGoodsName: [item.certificatePrintingName], //货物名称
								// 	hw_type: [item.cateother], //项目类别
								// 	ownerGoodsId: [item.useDgoodsId], //企业常用危险货物包装ID
								// 	category: [item.category], //类别
								// 	termOther: [item.termOther], //项别
								// 	unCode: [item.unNo], //联合国编号
								// 	ownerGoodsAlias: [item.transportName], //正式运输名称
								// 	hw_ggList: [item.list], //包装规格集合
								// 	hw_gg: [ggFirst.packingSpec], //包装规格
								// 	hw_category: [ggFirst.packCategory], //类别
								// }
							}).catch(err => {
								// console.log(err);
								if (err == '没有查询到数据') {
									uni.showToast({
										title: '请重新配置车辆常用货物',
										icon: 'none'
									})
								}
							});
					}
				})
			}
		},
		computed: {
			userInfo() {
				return this.$store.getters.getUserInfo;
			}
		},
		mounted() {
			let arr = this.$store.getters.getRegionData
			console.log(arr)
			arr.forEach((el, i) => {
				this.optionsxl.push({
					label: el.title,
					value: `${el.value}0000`
				})
			})
			this.$api.queryEmpType({
				idCard: this.userInfo.empIdCard,
			}).then(res => {
				// console.log(res, 222);
				// 人员信息
				this.userEmpInfo = res.data.data;
			})
			this.userType = this.$store.getters.getUserType;

			this.regionData = this.$store.getters.getRegionData; // 去掉第一个“中华人民共和国”

			//page 驾押列表 1    驾押复制2  企业复制3
			if (this.options.page == 1) {
				//1.获取驾押人员运输信息
				this.getYsMessage()
			} else if (this.options.page == 2) { //驾押复制2
				this.$api.carPersonDetail({
					'taskId': this.options.taskId,
					'dispCheckId': this.options.dispCheckId
				}).then(value => {
					// escortIdCard
					this.$api.queryEmpType({
						idCard: value.data['data'].escortIdCard,
					}).then(res => {
						// 人员信息
						if (res.data.data) {
							this.ysMsgMap.escortName = value.data['data']['escortName'];
							this.ysMsgMap.escortIdNumber = value.data['data']['escortIdCard'];
							this.ysMsgMap.escortEmpInfoId = value.data['data']['escortEmpInfoId'];
							this.ysMsgMap.escortTel = value.data['data']['escortMobilePhone'];
						} else {
							this.ysMsgMap.escortName = ''
							this.ysMsgMap.escortIdNumber = '';
							this.ysMsgMap.escortEmpInfoId = '';
							this.ysMsgMap.escortTel = '';
						}
					})
					this.ysMsgMap.vehCode = value.data['data']['vehCode'];
					this.ysMsgMap.trailerVehCode = value.data['data']['trailerVehCode'];
					this.ysMsgMap.driverName = value.data['data']['driverName'];
					this.ysMsgMap.driverIdNumber = value.data['data']['driverIdCard'];
					// this.ysMsgMap.escortName = value.data['data']['escortName'];
					// this.ysMsgMap.escortIdNumber = value.data['data']['escortIdCard'];
					this.ysMsgMap.vehId = value.data['data']['vehId'];
					this.ysMsgMap.trailerVehId = value.data['data']['trailerId'];
					this.ysMsgMap.vehColor = value.data['data']['vehColor'];
					this.ysMsgMap.driverTel = value.data['data']['driverMobilePhone'];
					this.ysMsgMap.driverEmpInfoId = value.data['data']['driverEmpInfoId'];
					// console.log(value.data['data']);
					// console.log(this.ysMsgMap);
				}).catch(res => {})

				this.copyTask()
			} else if (this.options.page == 3) { //企业复制3
				this.copyTask()
			}
			this.$nextTick(() => {
				this.way_map.endTime = dateFormat(new Date(), 'YYYY-mm-dd')
				this.way_map.startTime = dateFormat(new Date(), 'YYYY-mm-dd')
			})
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			this.options = option;
		},
		methods: {
			// 下一步
			xyb(i){
				console.log(i)
				if(i == 1){
					this.jiaoyan()
					// this.tabsshow = 2
					return
				}
				if(i == 2){
					this.xhjy()
					// this.tabsshow = 3
					
					return
				}
			},
			// 装货校验
			jiaoyan(){
				if (this.userType == "1") {
					if (this.ysMsgMap.vehCode == '') {
						uni.showToast({
							title: '请选择车牌号',
							icon: 'none'
						})
						return;
					}
					// if (this.ysMsgMap.trailerVehCode == '') {
					// 	uni.showToast({
					// 		title: '请选择挂车牌号',
					// 		icon: 'none'
					// 	})
					// 	return;
					// }
				
					if (this.ysMsgMap.driverName == '') {
						uni.showToast({
							title: '请选择驾驶员',
							icon: 'none'
						})
						return;
					}
					if (this.ysMsgMap.escortName == '') {
						uni.showToast({
							title: '请选择押运员',
							icon: 'none'
						})
						return;
					}
					// console.log(this.ysMsgMap);
					if (this.ysMsgMap.driverIdNumber == this.ysMsgMap.escortIdNumber) {
						uni.showToast({
							title: '驾押人员不能为同一个人',
							icon: 'none'
						})
						return;
					}
				}
				// console.log(this.userEmpInfo);
				if (this.userInfo.userRoleType == 3) {
					if (this.userEmpInfo) {
						// type:人员类型：管理人员/驾驶员/押运员/驾押员  ->  1/2/3/4
						if (this.userEmpInfo.type == "2") {
							if (this.userEmpInfo.idCard != this.ysMsgMap.driverIdNumber) {
								uni.showToast({
									title: '请设置自己为驾驶员',
									icon: 'none'
								})
								return;
							}
						}
						if (this.userEmpInfo.type == "3") {
							if (this.userEmpInfo.idCard != this.ysMsgMap.escortIdNumber) {
								uni.showToast({
									title: '请设置自己为押运员',
									icon: 'none'
								})
								return;
							}
						}
						if (this.userEmpInfo.type == "4") {
							if (this.userEmpInfo.idCard != this.ysMsgMap.driverIdNumber && this.userEmpInfo.idCard != this
								.ysMsgMap.escortIdNumber) {
								uni.showToast({
									title: '请设置自己为驾驶员或押运员',
									icon: 'none'
								})
								return;
							}
						}
					} else {
						uni.showToast({
							title: '该人员已离职，无法创建任务！',
							icon: 'none'
						})
						return
					}
				}
				if (!this.yslxobj.label) {
					uni.showToast({
						title: '请选择运输类型',
						icon: 'none'
					})
					return
				}
				let errorFound = false
					this.hwinfohz.forEach((el, i) => {
									el.hw_map.ownerGoodsAlias.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息货物' + (index + 1) + '名称',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									el.hw_map.hw_num.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息货物' + (index + 1) + '数量',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									el.hw_map.hw_dw.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息货物' + (index + 1) + '单位名称',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									el.hw_map.hw_zl.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息货物' + (index + 1) + '重量',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									el.hw_map.hw_gg.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息货物' + (index + 1) + '包装规格',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
				
									el.hw_map.hw_zl.forEach((item, index) => {
										if (Number(item) >= 1000) {
											uni.showToast({
												title: '第' + (i + 1) + '个装货信息货物' + (index + 1) + '超重',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									
									if (el.ty_map.ty_name == '') {
										uni.showToast({
											title: '请输入第' + (i + 1) + '个装货信息托运方名称',
											icon: 'none'
										})
										errorFound = true
										return
									}
									if (el.ty_map.ty_phoneNum == '') {
										uni.showToast({
											title: '请输入第' + (i + 1) + '个装货信息托运方联系电话',
											icon: 'none'
										})
										errorFound = true
										return
									}
									const phoneReg= /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/;
									const addressReg=
										/[`~～!@#$%^&*_\+=|\/\\[\]·~！@#￥%……&*——\+=]|(\ud83c[\udc00-\udfff])|(\ud83d[\udc00-\udfff])|(\ud83e[\udc00-\udfff])|[\u2100-\u32ff]|[\u0030-\u007f][\u20d0-\u20ff]|[\u0080-\u00ff]/g;
									if (!phoneReg.test(el.ty_map.ty_phoneNum)) {
										uni.showToast({
											title: '第' + (i + 1) + '个装货信息托运方电话格式不正确',
											icon: 'none'
										})
										errorFound = true
										return
									}
									if(el.ty_map.ty_tyshxy == ''){
										uni.showToast({
											title: '请输入第' + (i + 1) + '个装货信息托运方社会信用代码',
											icon: 'none'
										})
										errorFound = true
										return
									}
									let regtys = /^[0-9a-zA-Z]{18,}$/;
									let regty = /^[0-9a-zA-Z]{1,18}$/;
									if (!regty.test(el.ty_map.ty_tyshxy)) {
										uni.showToast({
											title: '第' + (i + 1) + '个装货信息托运方社会信用代码不能大于18位',
											icon: 'none'
										})
										errorFound = true
										return
									}
									if (!regtys.test(el.ty_map.ty_tyshxy)) {
										uni.showToast({
											title: '第' + (i + 1) + '个装货信息托运方社会信用代码不能小于18位',
											icon: 'none'
										})
										errorFound = true
										return
									}
									// 装货
									el.zh_map.zh_name.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '第' + (i + 1) + '个装货信息装货方名称',
												icon: 'none'
											})
											errorFound = true
											return;
										}
									})
									el.zh_map.zh_phoneNum.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个装货信息装货方联系电话',
												icon: 'none'
											})
											errorFound = true
											return;
										}
									})
				
									if (!phoneReg.test(el.zh_map.zh_phoneNum[0])) {
										uni.showToast({
											title: '第' + (i + 1) + '个装货信息装货方电话格式不正确',
											icon: 'none'
										})
										errorFound = true
										return
									}
									el.zh_map.zh_dqCode.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '第' + (i + 1) + '个装货信息装货方所在地区',
												icon: 'none'
											})
											errorFound = true
											return;
										}
									})
									el.zh_map.zh_address.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '第' + (i + 1) + '个装货信息装货方详细地址',
												icon: 'none'
											})
											errorFound = true
											return;
										}
									})
				                  if(el.zh_map.zh_tyshxy == ''){
										 uni.showToast({
										 	title: '第' + (i + 1) + '个装货信息装货方社会信用代码不能为空',
										 	icon: 'none'
										 })
										 errorFound = true
										 return
									 }
				    //             let regzh = /^[0-9a-zA-Z]{18,}$/;
								// // let regtys = /^[0-9a-zA-Z]{18,}$/;
								// let regzhs = /^[0-9a-zA-Z]{1,18}$/;
				    //             if (!regzh.test(el.zh_map.zh_tyshxy)) {
				    //             	uni.showToast({
				    //             		title: '第' + (i + 1) + '个装货信息装货方社会信用代码格式不正确',
				    //             		icon: 'none'
				    //             	})
								// 	errorFound = true
				    //             	return
				    //             }
								
								let regzhs = /^[0-9a-zA-Z]{1,18}$/;
								let regzh = /^[0-9a-zA-Z]{18,}$/;
								if (!regzh.test(el.zh_map.zh_tyshxy)) {
									uni.showToast({
										title: '第' + (i + 1) + '个装货信息装货方社会信用代码不能小于18位',
										icon: 'none'
									})
									errorFound = true
									return
								}
								if (!regzhs.test(el.zh_map.zh_tyshxy)) {
									uni.showToast({
										title: '第' + (i + 1) + '个装货信息装货方社会信用代码不能大于18位',
										icon: 'none'
									})
									errorFound = true
									return
								}
									if (addressReg.test(el.zh_map.zh_address[0])) {
										uni.showToast({
											title: '第' + (i + 1) + '个装货信息装货方详细地址不能包含特殊字符！',
											icon: 'none'
										})
										errorFound = true
										return
									}
				
								})
								 if (!errorFound) {
								        this.tabsshow = 2
								        // 如果没有发现错误，则执行后续逻辑
								    }
			},
			// 卸货校验
			xhjy(){
				let errorFound = false
				this.xhinfohz.forEach((el, i) => {
									// console.log(el,88)
									el.sh_map.sh_name.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请选择第' + (i + 1) + '个卸货信息卸货方名称',
												icon: 'none'
											})
											errorFound = true
											return
										}
									})
									el.sh_map.sh_phoneNum.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请选择第' + (i + 1) + '个卸货信息卸货方联系电话',
												icon: 'none'
											})
											errorFound = true
											return
										}
									})
				const phoneReg= /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/;
									const addressReg=
										/[`~～!@#$%^&*_\+=|\/\\[\]·~！@#￥%……&*——\+=]|(\ud83c[\udc00-\udfff])|(\ud83d[\udc00-\udfff])|(\ud83e[\udc00-\udfff])|[\u2100-\u32ff]|[\u0030-\u007f][\u20d0-\u20ff]|[\u0080-\u00ff]/g;
									if (!phoneReg.test(el.sh_map.sh_phoneNum[0])) {
										uni.showToast({
											title: '第' + (i + 1) + '个卸货信息卸货方电话格式不正确',
											icon: 'none'
										})
										errorFound = true
										return
									}
									el.sh_map.sh_dqCode.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请选择第' + (i + 1) + '个卸货信息卸货方所在地区',
												icon: 'none'
											})
											errorFound = true
											return
										}
									})
									el.sh_map.sh_address.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个卸货信息卸货方详细地址',
												icon: 'none'
											})
											errorFound = true
											return
										}
									})
				
									if (addressReg.test(el.sh_map.sh_address[0])) {
										uni.showToast({
											title: '第' + (i + 1) + '个卸货信息卸货方详细地址不能包含特殊字符！',
											icon: 'none'
										})
										errorFound = true
										return
									}
									console.log(el.sh_map.valuexh,777)
									el.sh_map.valuexh.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请选择第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息',
												icon: 'none'
											})
											errorFound = true
											return
										}
									})
									// if(el.sh_map.valuexh.length == 0){
									// 	uni.showToast({
									// 		title: '请选择第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息',
									// 		icon: 'none'
									// 	})
									// 	errorFound = true
									// 	return
									// }
									if(el.sh_map.sh_tyshxy == ''){
										uni.showToast({
											title: '请输入第' + (i + 1) + '个卸货信息卸货方社会信用代码',
											icon: 'none'
										})
										errorFound = true
										return
									}
									let regsh = /^[0-9a-zA-Z]{18,}$/;
									if (!regsh.test(el.sh_map.sh_tyshxy)) {
										uni.showToast({
											title: '第' + (i + 1) + '个卸货信息社会信用代码格式不正确',
											icon: 'none'
										})
										errorFound = true
										return
									}
									let regzhs = /^[0-9a-zA-Z]{1,18}$/;
									let regzh = /^[0-9a-zA-Z]{18,}$/;
									if (!regzh.test(el.sh_map.sh_tyshxy)) {
										uni.showToast({
											title: '第' + (i + 1) + '个卸货信息社会信用代码不能小于18位',
											icon: 'none'
										})
										errorFound = true
										return
									}
									if (!regzhs.test(el.sh_map.sh_tyshxy)) {
										uni.showToast({
											title: '第' + (i + 1) + '个卸货信息社会信用代码不能大于18位',
											icon: 'none'
										})
										errorFound = true
										return
									}
									
									el.sh_map.hw_num.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息数量',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
									// el.sh_map.hw_dw.forEach((item, index) => {
									// 	if (item == '') {
									// 		uni.showToast({
									// 			title: '请输入第' + (i + 1) + '个卸货信息的单位名称',
									// 			icon: 'none'
									// 		})
									// 		errorFound = true
									// 		return 
									// 	}
									// })
									console.log(el.sh_map.hw_zl,777)
									el.sh_map.hw_zl.forEach((item, index) => {
										if (item == '') {
											uni.showToast({
												title: '请输入第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息重量',
												icon: 'none'
											})
											errorFound = true
											return 
										}
									})
											
									
								})
								if (!errorFound) {
								       this.tabsshow = 3
								       // 如果没有发现错误，则执行后续逻辑
								   }
			},
			syb(i){
				console.log(i)
				if(i == 1){
					uni.showToast({
						title: '已返回到第一页',
						icon: 'none'
					})
				}
				if(i == 2){
					this.tabsshow = 1
					return
				}
				if(i == 3){
					this.tabsshow = 2
					return
				}
			},
			// 上一步
			// 多选
			// selectChange(val, index) {
			//  console.log(val, index, 666, this.xhinfohz[index].sh_map.valuexh);
			//  this.xhinfohz[index].sh_map.valuexh.forEach((item,i)=>{
			// 	   if(item ==  this.xhinfohz[index].sh_map.valuexh[i]){
			// 		  		uni.showToast({
			// 		  			title: '同一卸货信息中不能选择相同货物',
			// 		  			icon: 'none'
			// 		  		})
			// 				// this.xhinfohz[index].sh_map.valuexh
			// 			this.xhinfohz[index].sh_map.valuexh.splice(i, 1);
			// 			return
			// 	   }else{
			// 		   let a = this.optionsxh.filter(ele => ele.value === item);
			// 		   console.log(a,7)
			// 	   }
			//  })
			
			// },
			selectChange(val, index) {
			    let uniqueValues = [];
			    this.xhinfohz[index].sh_map.valuexh.forEach((item,i) => {
			        if (!uniqueValues.includes(item)) {
			            uniqueValues.push(item);
						// this.xhinfohz[index].sh_map.hw_dw = []
						//  this.xhinfohz[index].sh_map.hw_dw.push('') 
						let selectedItem = this.optionsxh.find(ele => ele.value === item);
						 // this.xhinfohz[index].sh_map.hw_dw[i]= selectedItem.dw
						 // console.log(selectedItem,888)					 // this.xhinfohz[index].sh_map.valuexh.push(selectedItem.value)
						 this.$set(this.xhinfohz[index].sh_map.hw_dw, i, selectedItem.dw)
						// console.log( this.xhinfohz[index].sh_map.hw_dw,787,i);
			        } else {
						 // this.$set(this.xhinfohz[index].sh_map.hw_dw, i, '')
			            uni.showToast({
			                title: '同一卸货信息中不能选择相同货物',
			                icon: 'none'
			            });
			            // 如果需要移除重复元素，可以使用下面的代码
			            // let i = this.xhinfohz[index].sh_map.valuexh.indexOf(item);
						// .pop()
			            this.xhinfohz[index].sh_map.valuexh.splice(i, 1);
						 this.xhinfohz[index].sh_map.hw_dw.splice(i, 1);
						 this.xhinfohz[index].sh_map.hw_zl.splice(i, 1);
						  this.xhinfohz[index].sh_map.hw_num.splice(i, 1);
						
			        }
			    });
			},
			selectChangecode(val) {
				// console.log(val, 666, );

			},
			initHwNum(index, inx) {
				let num = Number(this.hwinfohz[inx].hw_map.hw_num[index]) || 0;
				this.$set(this.hwinfohz[inx].hw_map.hw_num, index, Number(num.toFixed(2)));
			},
			// initHwNums(index,m) {
			// 	let num = Number(this.xhinfohz[index].sh_map.hw_num[m]) || 0;
			// 	this.$set(this.xhinfohz[index].sh_map.hw_num, index, Number(num.toFixed(2)));
			// },
			clickDw(index, inx) {
				//父组件调用子组件方法
				this.$refs.child5.showBox({
					getData: this.select.dw.map(item => {
						item.$label = item.text;
						item.inx = inx
						return item;
					}),
					title: "请选择货物单位",
					data: index
				});
			},
			clickDws(index,inx) {
				//父组件调用子组件方法
				this.$refs.child10.showBox({
					getData: this.select.dw.map(item => {
						item.$label = item.text;
						item.inx = inx
						return item;
					}),
					title: "请选择货物单位",
					data: index,
					// inx:inx
				});
			},
			selectDw(res) {
				let item = res.item;
				let index = res.data;
				let inx = item.inx
				this.$set(this.hwinfohz[inx].hw_map.hw_dw, index, item.text)
				this.xhhwlb(1)
				this.xhhwsj()
				let arr = []
					this.optionsxh.forEach((el,i)=>{
						arr.push(el.value)
					})
					// console.log(arr,8882)
				let flg =this.hasDuplicate(arr)
				if(flg==true){
					this.delectHw(index,inx)
					uni.showToast({
					    title: '同一装货信息中不能选择相同货物',
					    icon: 'none'
					});
				}
			},
			hasDuplicate(arr) {
			    // 创建一个空的集合
			    let set = new Set();
			
			    // 遍历数组
			    for (let i = 0; i < arr.length; i++) {
			        // 如果集合中已经包含当前元素，则说明数组有重复元素，返回 true
			        if (set.has(arr[i])) {
			          
						 return true;
			        }
			        // 否则，将当前元素加入集合
			        set.add(arr[i]);
			    }
			    // 遍历完数组后，没有发现重复元素，返回 false
			    return false;
			},
			selectDws(res) {
				let item = res.item;
				let index = res.data;
				let inx = item.inx
				// console.log(index,"货物")
				this.$set(this.xhinfohz[inx].sh_map.hw_dw, index, item.text)
			},
			inputSearch(e, index, type, inx) {
				var value = e.detail.value
				// 输入框防抖
				clearTimeout(this.debounceTimer);
				// 每次进来的时候都将之前的清除掉，如果还没到毫秒的时候就将之前的清除掉，这样就不会触发之前setTimeout绑定的事件， 如果超过毫秒，之前的事件就会被触发下次进来的时候同样清除之前的timer
				this.debounceTimer = setTimeout(() => {
					//输入框没值了，清空搜索框条件数据
					if (!value) {
						// 设置为初始状态
						return;
					}
					this.doSearch(index, value, type, inx)
				}, 1000)
			},
			copyTask() {
				this.$api.ddDetail({
					// 'id': this.options.id,
					'taskId': this.options.taskId,
					// 'dispCheckId': this.options.dispCheckId
				}).then(res => {
					// this.hw_map.hw_ggList
					if (res.data.code == 200) {
						this.clearHw()
						this.clearSh()
						// this.clearZh()
			             // console.log(res.data,8989)
						this.isCity = res.data['data']["isCityDistribution"] == 1 ? true : false;
						this.isWeiF = res.data['data']["isMedicineDangerScrap"] == 1 ? true : false;
						
						// this.ty_map.custId = res.data['data']["consignSquareId"];
						// this.ty_map.ty_name = res.data['data']["consignSquareName"];
						// this.ty_map.ty_phoneNum = res.data['data']["consignSquareTel"];
						 this.yslxlist.forEach((ele,i)=>{
							 if(ele.value == res.data['data']["transType"]){
								 this.yslxobj.label = ele.packingSpec
								 this.yslxobj.value = ele.value
								 // console.log(ele,787)
								 // let index = e.detail.value;
								 let a = {
									 detail:{
										value:ele.value-1
									 }
								 }
								 this.yslxChange(0,a)
							 }
						 })
						 // 
						this.way_map.lineId = res.data['data']["lineId"];
						this.way_map.route = res.data['data']["lineName"];
						this.way_map.mileage = res.data.data.lineMileage
						this.way_map.startTime = res.data['data']["estimateLoadingTime"];
						this.way_map.endTime = res.data['data']["estimateUnloadingTime"];
			            this.way_map.valuexl = res.data['data']["throughProvinces"]?res.data['data']["throughProvinces"].split(","):[]  
						 // console.log( this.way_map.valuexl,8989,this.optionsxl)
						 let zhobj = res.data.data.busiTaskDetailInVoExtend.loadGoodsVos
					    let xhobj = res.data.data.busiTaskDetailInVoExtend.unLoadGoodsVos
					 this.zhhxon(zhobj)
					 this.xhhxon(xhobj)
					 
						if(this.way_map.endTime == ''){
													this.way_map.endTime = dateFormat(new Date(), 'YYYY-mm-dd') 
						}
						if(this.way_map.startTime == ''){
												 this.way_map.startTime = dateFormat(new Date(), 'YYYY-mm-dd')
						}
					} else {
						uni.showToast({
							title: '服务异常',
							icon: 'none'
						})
					}
				}).catch(res => {})
			},
			// 回显货物集合装货
			zhhxon(arr){
				arr.forEach((ele, i) => {
					// console.log(ele,77777)
					// this.hwinfohz
					this.hwinfohz.push({
					//托运方map
					ty_map: {
						ty_name: "", //托运方名称
						ty_phoneNum: "", //托运方联系电话
						custId: "", //托运方id
						ty_tyshxy: '',
						ty_ssht: '',
						ty_sshtid: '', //所属合同id
						hwtyht: []
					},
					//货物信息集合
					hw_map: {
						ownerGoodsName: [], //货物名称
						hw_gg: [], //包装规格
						hw_type: [], //项目类别
						hw_num: [], //货物数量
						hw_zl: [], //货物重量
						hw_dw: [], //单位
						hw_category: [], //类别
						ownerGoodsId: [], //企业常用危险货物包装ID
						hw_ggList: [
						], //包装规格集合
						category: [], //类别
						termOther: [], //项别
						ownerGoodsPkg: [], ////企业常用危险货物包装ID
						unCode: [], //联合国编号
						ownerGoodsAlias: [], //正式运输名称
						taskGoodsId:''
					},
					//装货方
					zh_map: {
						zh_name: [], //名称
						zh_phoneNum: [], //联系电话
						zh_dq: [], //所在地区
						zh_address: [], //详细地址
						zh_dqCode: [], //所在地区code
						zh_dqLocation: [], //所在地区经纬度
						zh_location: [], //装货方经纬度
						zh_corpCustId: [], //装货公司客户ID
						zh_contactsName: [], //装货联系人名称
						zh_custAddrId: [], //装货客户地址ID
						zh_tyshxy: ''
					},
				})
				ele.busiTaskgoodsList.forEach((item,index)=>{
					this.hwinfohz[i].hw_map.ownerGoodsId.push(item.ownerGoodsId)
					this.hwinfohz[i].hw_map.ownerGoodsPkg.push(item.ownerGoodsPkg)
					this.hwinfohz[i].hw_map.unCode.push(item.unCode)
					this.hwinfohz[i].hw_map.ownerGoodsName.push(item.ownerGoodsName)
					this.hwinfohz[i].hw_map.ownerGoodsAlias.push(item.ownerGoodsAlias)
					this.hwinfohz[i].hw_map.category.push(item.category)
					this.hwinfohz[i].hw_map.termOther.push(item.termOther)
					var cate = item.category == "" ? "" : item.category + "类";
					var other = item.termOther == "" ? "" : item.termOther + "项";
					this.hwinfohz[i].hw_map.hw_type.push(cate + other)
					this.hwinfohz[i].hw_map.hw_gg.push(item.pkgSpec)
					this.hwinfohz[i].hw_map.hw_category.push(item.pkgCategory)
					this.hwinfohz[i].hw_map.hw_ggList.push(item.termOther)
					this.hwinfohz[i].hw_map.taskGoodsId = item.taskGoodsId
					this.hwinfohz[i].hw_map.hw_zl.push(item.goodsWeight)
					this.hwinfohz[i].hw_map.hw_num.push(item.goodsNumber)
					this.hwinfohz[i].hw_map.hw_dw.push(item.goodsUnit)
				})
				
				this.hwinfohz[i].ty_map = {
					custId: ele.consign.consignSquareId,
					ty_name: ele.consign.consignSquareName,
					ty_phoneNum: ele.consign.consignSquareTel,
					ty_tyshxy: ele.consign.consignSocialCreditCode,
					ty_sshtid:ele.consign.consignContractId,
					ty_ssht:''
				}
						this.ckhuixina(ele.consign.consignSquareName,i)
						
						this.hwinfohz[i].zh_map.zh_corpCustId.push(ele.load.corpCustId)
						this.hwinfohz[i].zh_map.zh_custAddrId.push(ele.load.custAddrId)
						this.hwinfohz[i].zh_map.zh_name.push(ele.load.comName)
						this.hwinfohz[i].zh_map.zh_contactsName.push(ele.load.contactsName)
						this.hwinfohz[i].zh_map.zh_phoneNum.push(ele.load.contactsTel)
						this.hwinfohz[i].zh_map.zh_dqCode.push(ele.load.zipCode)
						this.hwinfohz[i].zh_map.zh_dq.push(ele.load.zipCode)
						this.getJw(ele.load.zipCode,0,2,i)
						this.getJw(ele.load.addr,0,1,i)
						// this.changeAdrZ(0,ele.load.zipCode,i)
						this.hwinfohz[i].zh_map.zh_address.push(ele.load.addr)
						this.hwinfohz[i].zh_map.zh_tyshxy = ele.load.socialCreditCode
						
					
				})	
				// console.log(this.hwinfohz,88)
			},
			// 查看合同
			ckhuixina(name,i){
				this.$api.listByOwner().then(res => {
					if (res.data.code == 200) {
						// console.log(name,i,888,res.data.data)
						this.hwinfohz[i].ty_map.hwtyht = []
						res.data.data.forEach((els, ix) => {
							if (els.consignSquareName == name) {
								// this.hwinfohz.forEach((item,index)=>{
									this.hwinfohz[i].ty_map.hwtyht.push({
											value: els.id,
											packingSpec: els.contractName
									})
								// })
								
								let e = {
									detail:{
										value: ix
									}
								}
								// console.log(this.hwinfohz[i].ty_map.hwtyht)
								this.hwtyhtChange(0,e,i,2)
								 // this.hwinfohz[i].ty_map.ty_sshtid = els.id
							}
						})
						}
						})
						// this.hwinfohz[i].ty_map.hwtyht.forEach((el,i)=>{
						// if(el.value == this.hwinfohz[i].ty_map.ty_sshtid){
						// 	 console.log(el,'ht')
		    //           this.hwinfohz[i].ty_map.ty_ssht = el.packingSpec 
					 
						// }
						// })
			},
			// 回显货物集合卸货
			xhhxon(arr){
				this.xhhwlb(1)
				arr.forEach((ele,i)=>{
					
					this.xhinfohz.push({//收货方
					sh_map: {
					sh_tyshxy: '',
			        sh_name: [], //名称
			        sh_phoneNum: [], //联系电话
			        sh_dq: [], //所在地区
			        sh_address: [], //详细地址
			        sh_dqCode: [], //所在地区code
			        sh_dqLocation: [], //所在地区经纬度
			        sh_location: [], //收获方经纬度
			        sh_corpCustId: [], //收货公司客户ID                         
			        sh_contactsName: [], //收货联系人名称  
			        sh_custAddrId: [], ////装货客户地址ID	
			        // optionsxh:[],
					hw_num: [], //货物数量
					hw_zl: [], //货物重量
					hw_dw: [], //单位
			        valuexh: [],
						},
					})
					// console.log(ele,898555)
				this.xhinfohz[i].sh_map.sh_tyshxy = ele.unLoad.socialCreditCode
				this.xhinfohz[i].sh_map.sh_corpCustId.push(ele.unLoad.corpCustId)
				this.xhinfohz[i].sh_map.sh_custAddrId.push(ele.unLoad.custAddrId)
				this.xhinfohz[i].sh_map.sh_name.push(ele.unLoad.comName)
				this.xhinfohz[i].sh_map.sh_contactsName.push(ele.unLoad.contactsName)
				this.xhinfohz[i].sh_map.sh_phoneNum.push(ele.unLoad.contactsTel)
				this.xhinfohz[i].sh_map.sh_dqCode.push(ele.unLoad.zipCode)
				this.xhinfohz[i].sh_map.sh_dq.push(ele.unLoad.zipCode)
				this.xhinfohz[i].sh_map.waybillNo=ele.unLoad.waybillNo
				this.getJw(ele.unLoad.zipCode,0,4,i)
				this.getJw(ele.unLoad.addr,0,3,i)
				this.xhinfohz[i].sh_map.sh_address.push(ele.unLoad.addr)
			
				// this.changeAdrS(i)
				ele.goods.forEach((item, index) => {
					// console.log(item,888,'wowswowo')
					let a = `${item.loadSortNo},${item.ownerGoodsId},${item.goodsUnit},${item.pkgSpec}`
					// console.log(item,888,a)
					// let a = item.split(",")
					// console.log(a,888,a[0])  goodsUnit  pkgSpec
					// ${i+1},${el.hw_map.ownerGoodsId[index]}
					this.xhinfohz[i].sh_map.valuexh.push(`${item.loadSortNo},${item.ownerGoodsId},${item.goodsUnit},${item.pkgSpec}`)
					this.xhinfohz[i].sh_map.hw_zl.push(item.goodsWeight)
					this.xhinfohz[i].sh_map.hw_num.push(item.goodsNumber)
					this.xhinfohz[i].sh_map.hw_dw.push(item.goodsUnit)
				})
				
				// shMap[i].serialNo = (i+1)
				})
				// console.log(this.xhinfohz,898555)
			},
			okQy() {
					// 'id': this.options.id,
					// 				'taskId': this.options.taskId,
					// 				'dispCheckId': this.options.dispCheckId
				this.$goBack('./task_dispatch?dispCheckId=' + this.options.dispCheckId +
					'&taskId=' + this.options.taskId +
					'&id=' + this.options.id +
					'&type=2')
				// this.$goBack('./task_dispatch?category=' + this.hw_map.category +
				// 	'&termOther=' + this.hw_map.termOther +
				// 	'&goodsWeight=' + encodeURIComponent(JSON.stringify(this.hw_map.hw_zl)) +
				// 	'&goodsNumber=' + this.hw_map.hw_num +
				// 	'&hWmc=' + encodeURIComponent(JSON.stringify(this.hw_map.ownerGoodsName)) +
				// 	'&zHrq=' + this.way_map.startTime +
				// 	'&xHrq=' + this.way_map.endTime +
				// 	'&zAddress=' + encodeURIComponent(JSON.stringify(this.zh_map.zh_dq)) +
				// 	'&sAddress=' + encodeURIComponent(JSON.stringify(this.sh_map.sh_dq)) +
				// 	'&lineName=' + this.way_map.route +
				// 	'&xLlc=' + this.way_map.mileage +
				// 	'&taskId=' + this.taskId +
				// 	'&busiTaskgoodsList=' + encodeURIComponent(JSON.stringify(this.commitHwList())) +
				// 	'&type=1')
			},
			cancelQy() {
				this.$goBack('./qy_ts_mg', 4)
			},
			//调换到出车前检查
			okJc() {
				this.$goBack('/pages/dgs_qy/waybill/inspect/out-car?taskId=' + this.taskId +
					'&vehCode=' + this.ysMsgMap.vehCode +
					'&vehId=' + this.ysMsgMap.vehId +
					'&trailerId=' + this.ysMsgMap.trailerVehId +
					'&trailerVehCode=' + this.ysMsgMap.trailerVehCode +
					'&goodsInfo=' + this.goodsInfo +
					'&type=2')
			},
			//回到任务列表
			cancelJc() {
				let pages = getCurrentPages(); // 当前页面        
				let beforePage = pages[pages.length - 2]; // 上一页
				uni.navigateBack({
					success: () => {
						beforePage.$vm.reload();
					}
				});
			},
			//装货方获取所在地区
			changeAdrZ(index, text, inx) {
				
				this.hwinfohz[inx].zh_map.zh_dq[index] = text
				// console.log(666,text)
				// console.log(index,'shouhuo',text)
				this.getJw(this.hwinfohz[inx].zh_map.zh_dq[index], index, 2,inx)
				this.getJw(this.hwinfohz[inx].zh_map.zh_dq[index], index, 1,inx)
				this.getsfcode()
			},
			//收货方获取所在地区
			changeAdrS(index, text) {
				// if(index == this.xhinfohz.length-1){
					this.xhinfohz[index].sh_map.sh_dq[0] = text
					
					this.getJw(this.xhinfohz[index].sh_map.sh_dq[index], 0, 4,index)
						this.getJw(this.xhinfohz[index].sh_map.sh_dq[index], 0, 3,index)
					this.getsfcode()
				// }else{
				// 	this.changeAdrS(this.xhinfohz.length-1)
				// }
			
			},
			getSelectPath(value) {
				// console.log(value,444)
				// value = value[0]
				if (!value) {
					this.text = ''
					return [];
				}
				var path = [];
				topfor:
					for (let top of this.regionData) {
						if (value.startsWith(top.value)) {
							path[0] = top;
							if (top.children) {
								for (let child of top.children) {
									if (value.startsWith(child.value)) {
										path[1] = child;
										if (child.children) {
											for (let item of child.children) {
												if (item.value == value) {
													path[2] = item;
													break topfor;
												}
											}
										}
									}
								}
							}
						}
					}
					// this.text = path.map((item) => {
					// 	return item.title;
					// }).join('');
					return path.map((item) => {
						return item.value;
					});
					},
			getAreaCode(arr) {
			      if (arr && arr.length) {
					  let a = []
					  // a.push(arr[0].substring(0,2))
					  // console.log(this.regionData,767) //arr[0]
			        let obj1 = this.regionData.filter((v) => v.value == arr[0])[0];
			        let ret;
			        let obj2 =
			          obj1 &&
			          obj1.children &&
			          obj1.children.filter((v) => v.value == arr[1])[0];
			        if ((obj1 && obj1.title) == (obj2 && obj2.title)) {
			          ret = `${obj1 && obj1.title}` || "";
			        } else {
			          ret = `${obj1 && obj1.title}${obj2 && obj2.title}` || "";
			        }
			  // console.log(obj1,757,ret)
			        let obj3 =
			          obj2 &&
			          obj2.children &&
			          obj2.children.filter((v) => v.value == arr[2])[0];
			        if (obj3 && obj3.title) {
			          ret += `${obj3 && obj3.title}`;
			        }
					// console.log(ret,777)
			        return ret;
			      }
			    },
			//获取距离
			getDic(first, last, waypoints) {
				this.$api.getJuli({
					origin: first,
					destination: last,
					output: 'json',
					waypoints: waypoints.toString(),
					key: 'a5b6c60bf58424fbaaf0f4955ac9058a',
				}).then(res => {
					var distance = (res.data.route.paths[0].distance / 1000).toString().split(".")[0]
					//这显示行驶里程
					this.way_map.mileage = distance
				}).catch(res => {});
			},
			//获取经纬度集合
			getJwList(data) {
				data.forEach(item => {
					this.$api.getLocation({
						'address': item,
						'output': 'json',
						'key': 'a5b6c60bf58424fbaaf0f4955ac9058a'
					}).then(res => {
						this.locationList.push(res.data.geocodes[0].location)
					}).catch(res => {});
				});
			},
			doSearch(index, key = "", type, inx) {
				if (!key) {
					uni.showToast({
						title: '请输入关键词',
						icon: 'none'
					})
					return false;
				}
				if (type == '5') {
					this.hwmc(index, key, inx);
				} else if (type == '6') {
					this.tymc(key, inx);
				} else if (type == '7') {
					this.zhmc(index, key, inx);
				} else if (type == "8") {
					this.shmc(index, key)
				} else if (type == "9") {
					this.lineList(key)
				}
				else if (type == "11") {
					this.zhdz(index, key)
				}else if (type == "12") {
					this.shdz(index, key)
				}
			},
			//获取驾押人员运输信息
			getYsMessage() {
				//page 驾押列表 1    驾押复制2  企业复制3
				this.$api.createTaskgetYs({
					'idNumber': this.$store.getters.getEmpIdCard,
				}).then(res => {
					// console.log(res, 111);
					if (res.data.code == 200) {
						const resData = res.data.data || {};
						// console.log(resData);
						Object.assign(this.ysMsgMap, resData)
						// this.ysMsgMap = res.data.data
					}
				}).catch(() => {})
			},
			//取消
			cancal() {
				this.$goBack(1, 1)
			},
			//确认
			confirm() {
						      let errorFound = false
						      this.xhinfohz.forEach((el, i) => {
						      					// console.log(el,88)
						      					el.sh_map.sh_name.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请选择第' + (i + 1) + '个卸货信息卸货方名称',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return
						      						}
						      					})
						      					el.sh_map.sh_phoneNum.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请选择第' + (i + 1) + '个卸货信息卸货方联系电话',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return
						      						}
						      					})
						      const phoneReg= /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/;
						      					const addressReg=
						      						/[`~～!@#$%^&*_\+=|\/\\[\]·~！@#￥%……&*——\+=]|(\ud83c[\udc00-\udfff])|(\ud83d[\udc00-\udfff])|(\ud83e[\udc00-\udfff])|[\u2100-\u32ff]|[\u0030-\u007f][\u20d0-\u20ff]|[\u0080-\u00ff]/g;
						      					if (!phoneReg.test(el.sh_map.sh_phoneNum[0])) {
						      						uni.showToast({
						      							title: '第' + (i + 1) + '个卸货信息卸货方电话格式不正确',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					el.sh_map.sh_dqCode.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请选择第' + (i + 1) + '个卸货信息卸货方所在地区',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return
						      						}
						      					})
						      					el.sh_map.sh_address.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请输入第' + (i + 1) + '个卸货信息卸货方详细地址',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return
						      						}
						      					})
						      
						      					if (addressReg.test(el.sh_map.sh_address[0])) {
						      						uni.showToast({
						      							title: '第' + (i + 1) + '个卸货信息卸货方详细地址不能包含特殊字符！',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					console.log(el.sh_map.valuexh,777)
						      					el.sh_map.valuexh.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请选择第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return
						      						}
						      					})
						      					// if(el.sh_map.valuexh.length == 0){
						      					// 	uni.showToast({
						      					// 		title: '请选择第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息',
						      					// 		icon: 'none'
						      					// 	})
						      					// 	errorFound = true
						      					// 	return
						      					// }
						      					if(el.sh_map.sh_tyshxy == ''){
						      						uni.showToast({
						      							title: '请输入第' + (i + 1) + '个卸货信息卸货方社会信用代码',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					let regsh = /^[0-9a-zA-Z]{18,}$/;
						      					if (!regsh.test(el.sh_map.sh_tyshxy)) {
						      						uni.showToast({
						      							title: '第' + (i + 1) + '个卸货信息社会信用代码格式不正确',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					let regzhs = /^[0-9a-zA-Z]{1,18}$/;
						      					let regzh = /^[0-9a-zA-Z]{18,}$/;
						      					if (!regzh.test(el.sh_map.sh_tyshxy)) {
						      						uni.showToast({
						      							title: '第' + (i + 1) + '个卸货信息社会信用代码不能小于18位',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					if (!regzhs.test(el.sh_map.sh_tyshxy)) {
						      						uni.showToast({
						      							title: '第' + (i + 1) + '个卸货信息社会信用代码不能大于18位',
						      							icon: 'none'
						      						})
						      						errorFound = true
						      						return
						      					}
						      					
						      					el.sh_map.hw_num.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请输入第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息数量',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return 
						      						}
						      					})
						      					// el.sh_map.hw_dw.forEach((item, index) => {
						      					// 	if (item == '') {
						      					// 		uni.showToast({
						      					// 			title: '请输入第' + (i + 1) + '个卸货信息的单位名称',
						      					// 			icon: 'none'
						      					// 		})
						      					// 		errorFound = true
						      					// 		return 
						      					// 	}
						      					// })
						      					// console.log(el.sh_map.hw_zl,777)
						      					el.sh_map.hw_zl.forEach((item, index) => {
						      						if (item == '') {
						      							uni.showToast({
						      								title: '请输入第' + (i + 1) + '个卸货信息第' + (index + 1) + '个卸货货物信息重量',
						      								icon: 'none'
						      							})
						      							errorFound = true
						      							return 
						      						}
						      					})
						      							
						      					
						      				})
						      				
						
										if (this.way_map.startTime == '') {
											uni.showToast({
												title: '请选择装货日期',
												icon: 'none'
											})
											errorFound = true
											return
										}
										if (this.way_map.endTime == '') {
											uni.showToast({
												title: '请选择卸货日期',
												icon: 'none'
											})
											errorFound = true
											return
										}
										if (this.way_map.mileage == '') {
											uni.showToast({
												title: '请输入线路里程',
												icon: 'none'
											})
											errorFound = true
											return
										}
										if (this.way_map.valuexl.length == 0) {
											uni.showToast({
												title: '请选择途径省份',
												icon: 'none'
											})
											errorFound = true
											return
										}
										
							//如果userType==1是驾押提交 
							// if (this.userType == "1") {
							// 	var cateOtherList = [];
							// 	this.hwinfohz.forEach((el, i) => {
							// 		el.hw_map.category.forEach((item, index) => {
							// 			var map = {
							// 				"category": el.hw_map.category[index],
							// 				"termOther": el.hw_map.termOther[index],
							// 				"ownerGoodsId": el.hw_map.ownerGoodsId[index],
							// 			};
							// 			cateOtherList.push(map)
							// 		});
							// 	})
							// 	// this.hw_map.category.forEach((item, index) => {
							// 	// 	var map = {
							// 	// 		"category": this.hw_map.category[index],
							// 	// 		"termOther": this.hw_map.termOther[index],
							// 	// 		"ownerGoodsId": this.hw_map.ownerGoodsId[index],
							// 	// 	};
							// 	// 	cateOtherList.push(map)
							// 	// });
							// 	//创建任务驾押验证
							// 	this.vehChecks(cateOtherList)
							// } else {
								//是企业人员提交
								if (!errorFound) {
								      this.qyTaskCommit()
								       // 如果没有发现错误，则执行后续逻辑
								   }
								
							// }
						},
			// 通用展示错误信息的函数
			 showToastWithMessage(message) {
			    uni.showToast({
			        title: message,
			        icon: 'none'
			    });
			    throw new Error(message); // 抛出异常以终止执行，注意这可能需要根据实际情况调整
			},
			
			// 通用校验函数
			//  validateField(fieldValue, errorMessage) {
			//     if (!fieldValue || fieldValue.trim() === '') {
			//           this.showToastWithMessage(errorMessage);
			//         return false;
			//     }
			//     return true;
			// },
			 validateField(fieldValue, errorMessage) {
			    // 检查是否为字符串，如果是，则进行trim操作
			    if (typeof fieldValue === 'string') {
			        if (fieldValue.trim() === '') {
			            console.error(errorMessage);
			            return false;
			        }
			    } else if (Array.isArray(fieldValue)) {
			        // 如果是数组，可能需要对数组的每个元素进行校验
			        fieldValue.forEach((item, index) => {
			            if (typeof item === 'string' && item.trim() === '') {
			                console.error(`第${index + 1}个${errorMessage}`);
			            }
			            // 对于数组内非字符串元素的处理可以根据具体需求编写
			        });
			    } else {
			        // 对于非字符串和非数组类型，根据具体情况处理
			        console.error(`非预期的数据类型：${errorMessage}`);
			        return false;
			    }
			    return true;
			},
			
			// 校验电话号码
			 validatePhoneNumber(phoneNumber, index, type = '装货方') {
			    const phoneReg = /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/;
			    if (!phoneReg.test(phoneNumber)) {
			          this.showToastWithMessage(`第${index + 1}个${type}电话格式不正确`);
			        return false;
			    }
			    return true;
			},
			
			// 校验社会信用代码
			 validateSocialCreditCode(code, index, type = '装货方') {
			    let reg = /^[0-9a-zA-Z]{18,}$/;
			    if (!reg.test(code)) {
			          this.showToastWithMessage(`第${index + 1}个${type}社会信用代码格式不正确`);
			        return false;
			    }
			    return true;
			},
			
			// 校验地址中是否含有特殊字符
			 validateAddress(address, index, type = '装货方') {
			    const addressReg = /[`~～!@#$%^&*_\+=|\/\\[\]·~！@#￥%……&*——\+=]|(\ud83c[\udc00-\udfff])|(\ud83d[\udc00-\udfff])|(\ud83e[\udc00-\udfff])|[\u2100-\u32ff]|[\u0030-\u007f][\u20d0-\u20ff]|[\u0080-\u00ff]/g;
			    if (addressReg.test(address)) {
			          this.showToastWithMessage(`第${index + 1}个${type}详细地址不能包含特殊字符！`);
			        return false;
			    }
			    return true;
			},
			//企业人员任务提交
						qyTaskCommit() {
							// if (this.isSubmitCreate !== '0') {
							// 	this.showToast('该任务已创建，请返回列表')
							// 	return;
							// }
							// this.isSubmitCreate = '1'
							this.$api.updateBill({
								"taskState": "2", //保存传1，确认传2
								"isCityDistribution": this.isCity ? 1 : 0,
								"isMedicineDangerScrap": this.isWeiF ? 1 : 0,
								// "consignSquareId": this.ty_map.custId,
								// "consignSquareName": this.ty_map.ty_name,
								// "consignSquareTel": this.ty_map.ty_phoneNum,
								"lineId": this.way_map.lineId,
								"lineName": this.way_map.route == "" ? "" : this.way_map.route,
								"lineMile": this.way_map.mileage == "" ? "" : this.way_map.mileage,
								"loadingDate": this.way_map.startTime,
								"unloadingDate": this.way_map.endTime,
								"transType": Number(this.yslxobj.value),
								"throughProvinces": this.way_map.valuexl.join(','), //途径省份
								// "receiveName": this.sh_map.sh_name[this.sh_map.sh_name.length - 1],
								"loadGoodsVos": this.commitHwList(),
								"unLoadGoodsVos": this.xiehu(),
								"id":this.options.id
							}).then(res => {
								if (res.data.code == 200) {
									uni.showToast({
										title: res.data.msg,
										icon: 'none'
									})
								setTimeout(() => {
									let pages = getCurrentPages(); // 当前页面        
									let beforePage = pages[pages.length - 2]; // 上上一页 
									uni.navigateBack({
										success: () => {
											beforePage.$vm.refresherList();
										}
									});
								}, 1500); // showToast默认时间
								}
							}).catch();
						},
			
			//创建任务驾押验证接口
			vehChecks(data) {
				// console.log(data,999)
				this.$api.vehCheck({
					'vehId': "",
					'taskId': "",
					'vehCode：': this.ysMsgMap.vehCode,
					'trailerVehCode': this.ysMsgMap.trailerVehCode,
					'busiTaskgoodsList': data,
				}).then(res => {
					if (res.data.code == 200) {
						if (res.data.data.vehErrorMsg != "") {
							this.showToast(res.data.data.vehErrorMsg)
						} else if (res.data.data.trailerErrorMsg != "") {
							this.showToast(res.data.data.trailerErrorMsg)
						} else {
							this.commitTask()
						}
					}
				}).catch();
			},
			//驾押提交任务
			commitTask() {
				var busiDispcheckVo = {
					"busiDispcheck": {
						"vehId": this.ysMsgMap.vehId,
						"vehCode": this.ysMsgMap.vehCode,
						"vehColor": this.ysMsgMap.vehColor,
						"trailerId": this.ysMsgMap.trailerVehId,
						"trailerVehCode": this.ysMsgMap.trailerVehCode,
						"driverEmpInfoId": this.ysMsgMap.driverEmpInfoId,
						"driverName": this.ysMsgMap.driverName,
						"driverMobilePhone": this.ysMsgMap.driverTel,
						"escortEmpInfoId": this.ysMsgMap.escortEmpInfoId,
						"escortName": this.ysMsgMap.escortName,
						"escortMobilePhone": this.ysMsgMap.escortTel,
					}
				};
				//1危废 0是同城
				var busiTaskVo = {
					"taskState": "2", //保存传1，确认传2
					"isCityDistribution": this.isCity ? 1 : 0,
					"isMedicineDangerScrap": this.isWeiF ? 1 : 0,
					// "consignSquareId": this.ty_map.custId,
					// "consignSquareName": this.ty_map.ty_name,
					// "consignSquareTel": this.ty_map.ty_phoneNum,
					"lineId": this.way_map.lineId,
					"lineName": this.way_map.route == "" ? "" : this.way_map.route,
					"lineMileage": this.way_map.mileage == "" ? "" : this.way_map.mileage,
					"estimateLoadingTime": this.way_map.startTime,
					"estimateUnloadingTime": this.way_map.endTime,
					"transType": Number(this.yslxobj.value),
					"throughProvinces": this.way_map.valuexl.join(','), //途径省份
					// "receiveName": this.sh_map.sh_name[this.sh_map.sh_name.length - 1],
					"loadGoodsVos": this.commitHwList(),
					"unLoadGoodsVos": this.xiehu()
					// "busiTaskgoodsList": this.commitHwList(),
					// "busiTaskaddrList": this.commitZs(),
				};
				if (this.isSubmitCreate !== '0') {
					return;
				}
				this.isSubmitCreate = '1'
				console.log(busiTaskVo,'提交数据')
				this.$api.createTask({
					'busiTaskVo': busiTaskVo,
					'busiDispcheckVo': busiDispcheckVo
				}).then(res => {
					if (res.data.code == 200) {
						this.showDialog = true
						this.taskId = res.data.data.data.taskId
						this.goodsInfo = res.data.data.data.taskName
					} else {
						this.showToast(res.data.msg)
					}
				}).catch(() => {
					this.isSubmitCreate = '0'
				});
			},
		
			//任务提交 货物集合
			commitHwList() {
				var hwList = [];
				// let arr = []
				this.hwinfohz.forEach((ele, i) => {
					// console.log(ele,77777)
					hwList.push({
					    busiTaskgoodsList:[],
						consign:{},
						load:{},
						serialNo:''
				})
					ele.hw_map.ownerGoodsName.forEach((item, index) => {
						hwList[i].busiTaskgoodsList.push({
							"ownerGoodsId": ele.hw_map.ownerGoodsId[index],
							"taskGoodsId":ele.hw_map.taskGoodsId,
							"ownerGoodsPkg": ele.hw_map.ownerGoodsPkg[index],
							"unCode": ele.hw_map.unCode[index],
							"ownerGoodsName": ele.hw_map.ownerGoodsName[index],
							"ownerGoodsAlias": ele.hw_map.ownerGoodsAlias[index],
							"category": ele.hw_map.category[index],
							"termOther": ele.hw_map.termOther[index],
							"pkgSpec": ele.hw_map.hw_gg[index],
							"pkgCategory": ele.hw_map.hw_category[index],
							"goodsWeight": parseFloat(ele.hw_map.hw_zl[index]),
							"goodsNumber": parseFloat(ele.hw_map.hw_num[index]),
							"goodsUnit": ele.hw_map.hw_dw[index],
							"loadSortNo": (i+1)
						})
						// hwList[i].busiTaskgoodsList.push(map)
					});
					// "consignSquareId": this.ty_map.custId,
					// "consignSquareName": this.ty_map.ty_name,
					// "consignSquareTel": this.ty_map.ty_phoneNum,
					hwList[i].consign = {
						"consignSquareId": ele.ty_map.custId,
						"consignSquareName": ele.ty_map.ty_name,
						"consignSquareTel": ele.ty_map.ty_phoneNum,
						"consignSocialCreditCode": ele.ty_map.ty_tyshxy,
						"consignContractId":ele.ty_map.ty_sshtid
					}
					let index = 0
					hwList[i].load =  {
						"addrType": 1,
						"corpCustId": ele.zh_map.zh_corpCustId[index],
						"custAddrId": ele.zh_map.zh_custAddrId[index],
						"comName": ele.zh_map.zh_name[index],
						"contactsName": ele.zh_map.zh_contactsName[index],
						"contactsTel": ele.zh_map.zh_phoneNum[index],
						"zipCode": ele.zh_map.zh_dqCode[index],
						"addr": ele.zh_map.zh_address[index],
						"finishTime": "",
						"finishFlag": 0,
						"socialCreditCode": ele.zh_map.zh_tyshxy,
						"coord":ele.zh_map.zh_location.join(','),
						'lon': ele.zh_map.zh_location.length > 0 && typeof ele.zh_map.zh_location[index] ===
							'string' ?
							(ele.zh_map.zh_location[index].includes(",") ? ele.zh_map.zh_location[index]
								.split(",")[0] : "") :
							"",
						'lat': ele.zh_map.zh_location.length > 0 && typeof ele.zh_map.zh_location[index] ===
							'string' ?
							(ele.zh_map.zh_location[index].includes(",") ? ele.zh_map.zh_location[index]
								.split(",")[1] : "") :
							""
					};
					hwList[i].serialNo = (i+1)
					// arr.push(hwList)
				})

				return hwList
			},
			
			xiehu(){
				
				var shMap = []
				this.xhinfohz.forEach((ele,i)=>{
					shMap.push({
					unLoad: {},
					goods: [],
					serialNo: ''
				})
				ele.sh_map.sh_name.forEach((item, index) => {
					var map = {
						"addrType": 2,
						"corpCustId": ele.sh_map.sh_corpCustId[index],
						"custAddrId": ele.sh_map.sh_custAddrId[index],
						"comName": ele.sh_map.sh_name[index],
						"contactsName": ele.sh_map.sh_contactsName[index],
						"contactsTel": ele.sh_map.sh_phoneNum[index],
						"zipCode": ele.sh_map.sh_dqCode[index],
						"addr": ele.sh_map.sh_address[index],
						"finishTime": "",
						"finishFlag": 0,
						"waybillNo":ele.sh_map.waybillNo,
						"socialCreditCode": ele.sh_map.sh_tyshxy,
						"coord":ele.sh_map.sh_location.join(','),
						'lon': ele.sh_map.sh_location.length > 0 && typeof ele.sh_map.sh_location[index] ===
							'string' ?
							ele.sh_map.sh_location[index].split(",")[0] || "" :
							"",
						'lat': ele.sh_map.sh_location.length > 0 && typeof ele.sh_map.sh_location[index] ===
							'string' ?
							ele.sh_map.sh_location[index].split(",")[1] || "" :
							"",
							
					};
					shMap[i].unLoad = map
				})
				ele.sh_map.valuexh.forEach((item, index) => {
					// console.log(item,888)
					let arr = ele.sh_map.valuexh[index].split(",")
					let slicedArr = arr.slice(3); 
					
					// 将截取后的数组用逗号拼接成字符串
					// let result = slicedArr.join(',');
					// console.log(a,888,a[0])
					shMap[i].goods.push({
						"loadSortNo": ele.sh_map.valuexh[index].split(",")[0],
						"ownerGoodsId":ele.sh_map.valuexh[index].split(",")[1],
						"goodsWeight": parseFloat(ele.sh_map.hw_zl[index]),
						"goodsNumber": parseFloat(ele.sh_map.hw_num[index]),
						"goodsUnit": ele.sh_map.hw_dw[index],
						// "pkgSpec":ele.sh_map.valuexh[index].split(",")[3],
						 "pkgSpec":slicedArr.join(','),
					})
				})
				
				shMap[i].serialNo = (i+1)
				})
				return shMap
			},
			//任务提交 装货 收获
			commitZs() {
				var zhMap = []
				var shMap = []
				var sumList = []
				this.zh_map.zh_name.forEach((item, index) => {
					var map = {
						"addrType": 1,
						"corpCustId": this.zh_map.zh_corpCustId[index],
						"custAddrId": this.zh_map.zh_custAddrId[index],
						"comName": this.zh_map.zh_name[index],
						"contactsName": this.zh_map.zh_contactsName[index],
						"contactsTel": this.zh_map.zh_phoneNum[index],
						"zipCode": this.zh_map.zh_dqCode[index],
						"addr": this.zh_map.zh_address[index],
						"finishTime": "",
						"finishFlag": 0,
						'lon': this.zh_map.zh_location.length > 0 && typeof this.zh_map.zh_location[index] ===
							'string' ?
							(this.zh_map.zh_location[index].includes(",") ? this.zh_map.zh_location[index]
								.split(",")[0] : "") :
							"",
						'lat': this.zh_map.zh_location.length > 0 && typeof this.zh_map.zh_location[index] ===
							'string' ?
							(this.zh_map.zh_location[index].includes(",") ? this.zh_map.zh_location[index]
								.split(",")[1] : "") :
							""
					};
					zhMap.push(map)
				});
				this.sh_map.sh_name.forEach((item, index) => {
					var map = {
						"addrType": 2,
						"corpCustId": this.sh_map.sh_corpCustId[index],
						"custAddrId": this.sh_map.sh_custAddrId[index],
						"comName": this.sh_map.sh_name[index],
						"contactsName": this.sh_map.sh_contactsName[index],
						"contactsTel": this.sh_map.sh_phoneNum[index],
						"zipCode": this.sh_map.sh_dqCode[index],
						"addr": this.sh_map.sh_address[index],
						"finishTime": "",
						"finishFlag": 0,
						'lon': this.sh_map.sh_location.length > 0 && typeof this.sh_map.sh_location[index] ===
							'string' ?
							this.sh_map.sh_location[index].split(",")[0] || "" :
							"",
						'lat': this.sh_map.sh_location.length > 0 && typeof this.sh_map.sh_location[index] ===
							'string' ?
							this.sh_map.sh_location[index].split(",")[1] || "" :
							""
					};
					shMap.push(map)
				});
				sumList = zhMap.concat(shMap)
				return sumList
			},
			//显示土司
			showToast(message) {
				uni.showToast({
					title: message,
					icon: 'none'
				})
			},
			//删除收货
			delectSh(index) {
				this.xhinfohz.splice(index, 1)
				this.getsfcode()
				// this.sh_map.sh_name.splice(index, 1);
				// this.sh_map.sh_phoneNum.splice(index, 1);
				// this.sh_map.sh_dq.splice(index, 1);
				// this.sh_map.sh_address.splice(index, 1);
				// this.sh_map.sh_dqCode.splice(index, 1);
				// this.sh_map.sh_location.splice(index, 1);
				// this.sh_map.sh_corpCustId.splice(index, 1);
				// this.sh_map.sh_contactsName.splice(index, 1);
				// this.sh_map.sh_custAddrId.splice(index, 1);
				// this.sh_map.sh_dqLocation.splice(index, 1);
			},
			//清空收货方
			clearSh() {
				this.xhinfohz = []
			},
			//新增收货方
			addSh() {
				this.xhinfohz.push({
					//收货方
					sh_map: {
						sh_tyshxy: '',
						sh_name: [""], //名称
						sh_phoneNum: [""], //联系电话
						sh_dq: [""], //所在地区
						sh_address: [""], //详细地址
						sh_dqCode: [""], //所在地区code
						sh_dqLocation: [""], //所在地区经纬度
						sh_location: [""], //收获方经纬度
						sh_corpCustId: [""], //收货公司客户ID                                        
						sh_contactsName: [""], //收货联系人名称  
						sh_custAddrId: [""], ////装货客户地址ID					
						// optionsxh:[],
						hw_num: [""], //货物数量
						hw_zl: [""], //货物重量
						hw_dw: [""], //单位
						valuexh: []
					},
				})
				// console.log(this.xhinfohz,555)
				this.getsfcode()
				// this.sh_map.sh_name.push("");
				// this.sh_map.sh_phoneNum.push("");
				// this.sh_map.sh_dq.push("");
				// this.sh_map.sh_address.push("");
				// this.sh_map.sh_dqCode.push("");
				// this.sh_map.sh_location.push("");
				// this.sh_map.sh_corpCustId.push("");
				// this.sh_map.sh_contactsName.push("");
				// this.sh_map.sh_custAddrId.push("");
				// this.sh_map.sh_dqLocation.push("");
			},
			//删除装货
			delectZh(index) {
				this.hwinfohz.splice(index, 1)
				this.xhhwlb(1)
				this.xhhwsj()
				this.getsfcode()
				// this.zh_map.zh_name.splice(index, 1);
				// this.zh_map.zh_phoneNum.splice(index, 1);
				// this.zh_map.zh_dq.splice(index, 1);
				// this.zh_map.zh_address.splice(index, 1);
				// this.zh_map.zh_dqCode.splice(index, 1);
				// this.zh_map.zh_location.splice(index, 1);
				// this.zh_map.zh_corpCustId.splice(index, 1);
				// this.zh_map.zh_contactsName.splice(index, 1);
				// this.zh_map.zh_custAddrId.splice(index, 1);
				// this.zh_map.zh_dqLocation.splice(index, 1);
			},
			//清空装货方
			
			//新增装货方
			addZh() {
				// this.zh_map.zh_name.push("");
				// this.zh_map.zh_phoneNum.push("");
				// this.zh_map.zh_dq.push("");
				// this.zh_map.zh_address.push("");
				// this.zh_map.zh_dqCode.push("");
				// this.zh_map.zh_location.push("");
				// this.zh_map.zh_corpCustId.push("");
				// this.zh_map.zh_contactsName.push("");
				// this.zh_map.zh_custAddrId.push("");
				// this.zh_map.zh_dqLocation.push("");
				this.hwinfohz.push({
					//托运方map
					ty_map: {
						ty_name: "", //托运方名称
						ty_phoneNum: "", //托运方联系电话
						custId: "", //托运方id
						ty_tyshxy: '',
						ty_ssht: '',
						ty_sshtid: '', //所属合同id
						hwtyht: []
					},
					//货物信息集合
					hw_map: {
						ownerGoodsName: [""], //货物名称
						hw_gg: [""], //包装规格
						hw_type: [""], //项目类别
						hw_num: [""], //货物数量
						hw_zl: [""], //货物重量
						hw_dw: [""], //单位
						hw_category: [""], //类别
						ownerGoodsId: [""], //企业常用危险货物包装ID
						hw_ggList: [
							[]
						], //包装规格集合
						category: [""], //类别
						termOther: [""], //项别
						ownerGoodsPkg: [""], ////企业常用危险货物包装ID
						unCode: [""], //联合国编号
						ownerGoodsAlias: [""] //正式运输名称
					},
					//装货方
					zh_map: {
						zh_name: [""], //名称
						zh_phoneNum: [""], //联系电话
						zh_dq: [""], //所在地区
						zh_address: [""], //详细地址
						zh_dqCode: [""], //所在地区code
						zh_dqLocation: [""], //所在地区经纬度
						zh_location: [""], //装货方经纬度
						zh_corpCustId: [""], //装货公司客户ID
						zh_contactsName: [""], //装货联系人名称
						zh_custAddrId: [""], //装货客户地址ID
						zh_tyshxy: ''
					},
				})
				this.xhhwlb(1)
				this.xhhwsj()
				this.getsfcode()
			},
			//装货方名称
			zhmc(index, key = "", inx) {
				this.$refs.child7.showBox({
					title: "请选择装货方名称",
					data: index,
					key,
					getData: (key, current) => {
						return new Promise(resolve => {
							this.$api.getTzs({
								'name': key,
								'type': "3",
								current,
								'size': 20,
							}).then(res => {
								const resData = res.data.data
								resData.records.forEach(item => {
									item.$label = item.name;
									item.inx = inx
								});
									console.log(resData,998)
								resolve(resData)
							}).catch(res => {});
						})
					}
				});
			},
			// 装货方选择地址
		zhdz(index, key = "", inx) {
			
			  let cusid = this.hwinfohz[inx].zh_map.zh_corpCustId[0]
		     let owid = this.userInfo.ownerId
			 // console.log(this.hwinfohz[inx].zh_map,991)
			 	
				if(cusid == ''){
						this.showToast('请先选择装货方名称')
						return
				}
				console.log(cusid,77,owid,992)
		 
			this.$refs.child11.showBox({
				title: "请选择装货方地址",
				data: index,
				key,
				getData: (key, current) => {
					return new Promise(resolve => {
						this.$api.pageList({
							'addrName': key,
							'custId': cusid,
							'ownerId': owid,
							current,
							'size': 20,
						}).then(res => {
							const resData = res.data.data
							resData.records.forEach(item => {
								item.$label = item.addrAll;
								item.inx = inx
							});
								// console.log(resData,998)
							resolve(resData)
						}).catch(res => {});
					})
				}
			});
		},
			//获取途径路线
			lineList(key = "") {
				this.$refs.child9.showBox({
					title: "请选择途径路线",
					key,
					getData: (key) => {
						return new Promise(resolve => {
							this.$api.getLineName({
								'current': 1,
								'lineName': key,
								'size': 1000,
							}).then(res => {
								const resData = res.data.data.records.map(item => {
									item.$label = item.lineName;
									return item;
								});
								resolve(resData)
							}).catch(res => {});
						})
					}
				});
			},
			selectLine(res) {
				let item = res.item;
				this.way_map.route = item.lineName
				this.way_map.mileage = item.lineMileage
				this.way_map.lineId = item.lineId
			},
			//收获名称
			shmc(index, key = "") {
				this.$refs.child8.showBox({
					title: "请选择收获方名称",
					data: index,
					key,
					getData: (key, current) => {
						return new Promise(resolve => {
							this.$api.getTzs({
								name: key,
								type: "2",
								current,
								size: 20,
							}).then(res => {
								const resData = res.data.data;
								resData.records.forEach(item => {
									item.$label = item.name;
								});
								resolve(resData);
							}).catch(res => {});
						})
					}
				});

			},
			// 收货地址
			shdz(index, key = "") {
				
				  let cusid = this.xhinfohz[index].sh_map.sh_corpCustId[0]
			     let owid = this.userInfo.ownerId
				 // console.log(this.hwinfohz[inx].zh_map,991)
				 	
					if(cusid == ''){
							this.showToast('请先选择卸货方地址')
							return
					}
					console.log(cusid,77,owid,992)
			 
				this.$refs.child12.showBox({
					title: "请选择卸货方地址",
					data: index,
					key,
					getData: (key, current) => {
						return new Promise(resolve => {
							this.$api.pageList({
								'addrName': key,
								'custId': cusid,
								'ownerId': owid,
								current,
								'size': 20,
							}).then(res => {
								const resData = res.data.data
								resData.records.forEach(item => {
									item.$label = item.addrAll;
									
								});
									// console.log(resData,998)
								resolve(resData)
							}).catch(res => {});
						})
					}
				});
			},
			//托运方名称
			tymc(key = '', inx) {
				this.$refs.child6.showBox({
					title: "请选择托运名称",
					key,
					getData: (key, current) => {
						return new Promise(resolve => {
							this.$api.getTzs({
								name: key,
								type: "1",
								current,
								size: 20,
							}).then(res => {
								const resData = res.data.data
								resData.records.forEach(item => {
									item.$label = item.name;
									item.inx = inx
								});
								resolve(resData);
							}).catch(res => {});
						})
					}
				});

			},
			//清空货物信息
			clearHw() {
				this.hwinfohz = []
				// 	this.xhhwlb(1)
				// this.xhhwsj()
			},
			//添加货物
			addHw(inx) {
				this.hwinfohz[inx].hw_map.ownerGoodsName.push("");
				this.hwinfohz[inx].hw_map.hw_gg.push("");
				this.hwinfohz[inx].hw_map.hw_type.push("");
				this.hwinfohz[inx].hw_map.hw_num.push("");
				this.hwinfohz[inx].hw_map.hw_zl.push("");
				this.hwinfohz[inx].hw_map.hw_dw.push("");
				this.hwinfohz[inx].hw_map.hw_category.push("");
				this.hwinfohz[inx].hw_map.ownerGoodsId.push("");
				this.hwinfohz[inx].hw_map.hw_ggList.push([]);
				this.hwinfohz[inx].hw_map.category.push("");
				this.hwinfohz[inx].hw_map.termOther.push("");
				this.hwinfohz[inx].hw_map.ownerGoodsPkg.push("");
				this.hwinfohz[inx].hw_map.unCode.push("");
				this.hwinfohz[inx].hw_map.ownerGoodsAlias.push("");
				this.xhhwlb(1)
				this.xhhwsj()
			},
			addHwxh(inx) {
				this.xhinfohz[inx].sh_map.valuexh.push("");
				// this.hwinfohz[inx].hw_map.hw_gg.push("");
				// this.hwinfohz[inx].hw_map.hw_type.push("");
				this.xhinfohz[inx].sh_map.hw_num.push("");
				this.xhinfohz[inx].sh_map.hw_zl.push("");
				this.xhinfohz[inx].sh_map.hw_dw.push("");
				// console.log(this.xhinfohz,7878)
			},
			//删除卸货信息
			delectHwxh(index, inx) {
				this.xhinfohz[inx].sh_map.valuexh.splice(index, 1);
				this.xhinfohz[inx].sh_map.hw_num.splice(index, 1);
				this.xhinfohz[inx].sh_map.hw_zl.splice(index, 1);
				this.xhinfohz[inx].sh_map.hw_dw.splice(index, 1);
				// this.hwinfohz[inx].hw_map.ownerGoodsName.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_gg.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_type.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_num.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_zl.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_dw.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_category.splice(index, 1);
				// this.hwinfohz[inx].hw_map.ownerGoodsId.splice(index, 1);
				// this.hwinfohz[inx].hw_map.hw_ggList.splice(index, 1);
				// this.hwinfohz[inx].hw_map.category.splice(index, 1);
				// this.hwinfohz[inx].hw_map.termOther.splice(index, 1);
				// this.hwinfohz[inx].hw_map.ownerGoodsPkg.splice(index, 1);
				// this.hwinfohz[inx].hw_map.unCode.splice(index, 1);
				// this.hwinfohz[inx].hw_map.ownerGoodsAlias.splice(index, 1)
			},
			//删除货物
			delectHw(index, inx) {
				this.hwinfohz[inx].hw_map.ownerGoodsName.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_gg.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_type.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_num.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_zl.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_dw.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_category.splice(index, 1);
				this.hwinfohz[inx].hw_map.ownerGoodsId.splice(index, 1);
				this.hwinfohz[inx].hw_map.hw_ggList.splice(index, 1);
				this.hwinfohz[inx].hw_map.category.splice(index, 1);
				this.hwinfohz[inx].hw_map.termOther.splice(index, 1);
				this.hwinfohz[inx].hw_map.ownerGoodsPkg.splice(index, 1);
				this.hwinfohz[inx].hw_map.unCode.splice(index, 1);
				this.hwinfohz[inx].hw_map.ownerGoodsAlias.splice(index, 1);
				this.xhhwlb(1)
				this.xhhwsj()
				// this.
				// this.hwbflist = []
				// this.hwinfohz.forEach((el,i)=>{
				// 	console.log(el)
				// 	if(el.hw_map.ownerGoodsAlias){

				// 		el.hw_map.ownerGoodsAlias.forEach((item,index)=>{
				// 			this.hwbflist.push(
				// 					 {
				// 				        id:item,
				// 				        name:`${i+1}-${item}-${index+1}`
				// 				    },
				// 				)
				// 		})
				// 	}

				// })
				// console.log(this.hwbflist,9999)
			},
			//托运方-名称
			tuoChange(res) {
				let item = res.item;
				// const index = e.detail.value;
				let inx = item.inx
				// console.log(item,998)
				this.hwinfohz[inx].ty_map.ty_name = item.name
				this.hwinfohz[inx].ty_map.ty_phoneNum = item.contactsTel
				this.hwinfohz[inx].ty_map.custId = item.custId
				this.hwinfohz[inx].ty_map.ty_tyshxy = item.creditCode
				this.$api.listByOwner().then(res => {
					if (res.data.code == 200) {
						// console.log(res,888)
						this.hwinfohz[inx].ty_map.hwtyht = []
						res.data.data.forEach((el, i) => {
							if (el.consignSquareName == item.name) {
								this.hwinfohz[inx].ty_map.hwtyht.push({
										value: el.id,
										packingSpec: el.contractName
							 	}

								)
							}
						})
						// this.hwtyht.push({
						//  value: '1',
						//  packingSpec: '一装一卸'
						// }

						// )
					}
				}).catch(res => {

				});
			},
			//装货方-名称
			zhChange(res) {
				let eindex = res.data;
				let item = res.item;
				let inx = item.inx
				// console.log(res, 888)
				// const index = e.detail.value;
				this.$set(this.hwinfohz[inx].zh_map.zh_name, eindex, item.name)
				this.$set(this.hwinfohz[inx].zh_map.zh_phoneNum, eindex, item.contactsTel)
				this.$set(this.hwinfohz[inx].zh_map.zh_corpCustId, eindex, item.custId)
				this.$set(this.hwinfohz[inx].zh_map.zh_contactsName, eindex, item.contacts)
				this.hwinfohz[inx].zh_map.zh_tyshxy = item.creditCode
				// this.$set()
				// this.xhinfohz[eindex].sh_map.sh_tyshxy = item.creditCode
				//code--->所在地区----->经纬度
				// this.$set(this.zh_map.zh_dq, eindex, "北京市")
					// console.log(item, 88866)
				if (item.list && item.list.length) {
					// console.log('是否转换地区',item.list)
					const firstItem = item.list[0];
					this.$set(this.hwinfohz[inx].zh_map.zh_dqCode, eindex, firstItem.azipCode)
					this.$set(this.hwinfohz[inx].zh_map.zh_address, eindex, firstItem.addrName)
					this.$set(this.hwinfohz[inx].zh_map.zh_custAddrId, eindex, item.list.length > 0 ? firstItem.addrId :
						'')
					this.getJw(firstItem.addrName, eindex, 1, inx)
					this.getsfcode()
				}
				//这里缺失一个code转地区接口
				// let res= this.getAdr('00')
			},
			// 装货地址
			//装货方-名称
			zhdzChange(res) {
				let eindex = res.data;
				let item = res.item;
				let inx = item.inx
				// console.log(res, 888)
			
					this.$set(this.hwinfohz[inx].zh_map.zh_dqCode, eindex, item.azipCode)
					this.$set(this.hwinfohz[inx].zh_map.zh_address, eindex, item.addrName)
					this.$set(this.hwinfohz[inx].zh_map.zh_custAddrId, eindex, item.addrId)
					this.getJw(item.addrName, eindex, 1, inx)
					this.getsfcode()
				// }
				//这里缺失一个code转地区接口
				// let res= this.getAdr('00')
			},
			//获取经纬度
			async getJw(data, index, type, inx) {
				
				await this.$api.getLocation({
					'address': data,
					'output': 'json',
					'key': 'a5b6c60bf58424fbaaf0f4955ac9058a'
				}).then(res => {
					if (type == 1) {
						this.hwinfohz[inx].zh_map.zh_location[index] = res.data.geocodes[0].location 
						 console.log(555,"---")
					} else if (type == 2) {
						this.hwinfohz[inx].zh_map.zh_dqLocation[index] = res.data.geocodes[0].location
						this.lisenter.push(res.data.geocodes[0].location)
					} else if (type == 3) {
						this.xhinfohz[inx].sh_map.sh_location[index] = res.data.geocodes[0].location
						console.log(555,"---")
					} else if (type == 4) {
						this.xhinfohz[inx].sh_map.sh_dqLocation[index] = res.data.geocodes[0].location
						this.lisenter.push(res.data.geocodes[0].location)
					}

				}).catch(res => {});
			},
			//收货方-名称
			shdzChange(res) {
				let eindex = res.data;
				let item = res.item;
				let index = 0
				// console.log(res, 777)
				// this.xhhwlb(1)
				// this.xhhwsj()
				// const index = e.detail.value;
				// this.$set(this.xhinfohz[eindex].sh_map.sh_name, index, item.name)
				// this.$set(this.xhinfohz[eindex].sh_map.sh_phoneNum, index, item.contactsTel)
				// this.$set(this.xhinfohz[eindex].sh_map.sh_corpCustId, index, item.custId)
				// this.$set(this.xhinfohz[eindex].sh_map.sh_contactsName, index, item.contacts)
				// this.$set()
				// this.xhinfohz[eindex].sh_map.sh_tyshxy = item.creditCode
				// if (item.list && item.list.length) {
				// 	const firstItem = item.list[0];
					this.$set(this.xhinfohz[eindex].sh_map.sh_dqCode, index, item.azipCode)
					this.$set(this.xhinfohz[eindex].sh_map.sh_address, index, item.addrName)
					this.$set(this.xhinfohz[eindex].sh_map.sh_custAddrId, index, item.addrId)
					this.getJw(item.addrName, index, 3, eindex)
					this.getsfcode()
				// }
			},
			// 收货地址
			shChange(res) {
				let eindex = res.data;
				let item = res.item;
				let index = 0
				// console.log(res, 777)
				this.xhhwlb(1)
				// this.xhhwsj()
				// const index = e.detail.value;
				this.$set(this.xhinfohz[eindex].sh_map.sh_name, index, item.name)
				this.$set(this.xhinfohz[eindex].sh_map.sh_phoneNum, index, item.contactsTel)
				this.$set(this.xhinfohz[eindex].sh_map.sh_corpCustId, index, item.custId)
				this.$set(this.xhinfohz[eindex].sh_map.sh_contactsName, index, item.contacts)
				// this.$set()
				this.xhinfohz[eindex].sh_map.sh_tyshxy = item.creditCode
				if (item.list && item.list.length) {
					const firstItem = item.list[0];
					this.$set(this.xhinfohz[eindex].sh_map.sh_dqCode, index, firstItem.azipCode)
					this.$set(this.xhinfohz[eindex].sh_map.sh_address, index, firstItem.addrName)
					this.$set(this.xhinfohz[eindex].sh_map.sh_custAddrId, index, item.list.length > 0 ? firstItem.addrId :
						'')
					this.getJw(firstItem.addrName, index, 3, eindex)
					this.getsfcode()
				}
			},
			// 清空数据
			xhhwsj() {
				this.xhinfohz.forEach((el, i) => {
					el.sh_map.valuexh = []
					// el.sh_map.valuexh.splice(index, 1);
					el.sh_map.hw_num= [""]
					el.sh_map.hw_zl= []
					el.sh_map.hw_dw= []
					this.$set(this.xhinfohz[i].sh_map.hw_zl, 0, [])
				})
			},
			// 卸货列表
			xhhwlb(type) {
				if (type == 1) {
					// console.log(55)
					this.optionsxh = []
					this.hwinfohz.forEach((el, i) => {
						// console.log(el)
						if (el.hw_map.ownerGoodsAlias) {

							el.hw_map.ownerGoodsAlias.forEach((item, index) => {
								if(item){
										console.log(el.hw_map,555)
									this.optionsxh.push({
										id: `${i+1}+${item}+${index}`,
										label: `${i+1}-${item}`,
									value: `${i+1},${el.hw_map.ownerGoodsId[index]},${el.hw_map.hw_dw[index]},${el.hw_map.hw_gg[index]}`,
										dw:el.hw_map.hw_dw[index],
										// type:el.hw_map.hw_type[index]
									
									}, )
								}
								
							})
						}

					})
					// console.log(this.hwbflist,9999)
				}
			},
			//货物信息-包装规格
			hwggChange(eindex, e, inx) {
				// console.log(this.hw_map.hw_ggList,999)
				// console.log(e,999)
				// let inx = inx
				const index = e.detail.value;
				const hw_ggList = this.hwinfohz[inx].hw_map.hw_ggList[eindex];
				if (hw_ggList.length) {
					this.$set(this.hwinfohz[inx].hw_map.hw_gg, eindex, hw_ggList[index].packingSpec)
					this.$set(this.hwinfohz[inx].hw_map.hw_category, eindex, hw_ggList[index].packCategory)
					this.$set(this.hwinfohz[inx].hw_map.ownerGoodsPkg, eindex, hw_ggList[index].ownerGoodsPkg)
				}
			},
			// 运输类型
			yslxChange(eindex, e) {
				// console.log(e,888)
					let index = e.detail.value;
				if (this.yslxlist[index].value == '1') {
					if(this.hwinfohz.length > 1){
						uni.showToast({
							title: '运输类型与装卸货信息不匹配，请按照“一装一卸”运输类型填写对应的装卸货信息',
							icon: 'none',
							 duration: 3000
						})
						return
					}
					if(this.xhinfohz.length > 1){
						uni.showToast({
							title: '运输类型与装卸货信息不匹配，请按照“一装一卸”运输类型填写对应的装卸货信息',
							icon: 'none',
							 duration: 3000
						})
						return
					}
					// console.log(this.yslxlist, 888)
				
					this.yslxobj.label = this.yslxlist[index].packingSpec
					this.yslxobj.value = this.yslxlist[index].value
					this.zhshow = false
					this.shshow = false
				} else if (this.yslxlist[index].value == '2') {
					if(this.hwinfohz.length > 1){
						uni.showToast({
							title: '运输类型与装卸货信息不匹配，请按照“一装多卸”运输类型填写对应的装卸货信息',
							icon: 'none',
							 duration: 3000
						})
						return
					}
					this.yslxobj.label = this.yslxlist[index].packingSpec
					this.yslxobj.value = this.yslxlist[index].value
					this.zhshow = false
					this.shshow = true
				} else if (this.yslxlist[index].value == '3') {
				
					if(this.xhinfohz.length > 1){
						uni.showToast({
							title: '运输类型与装卸货信息不匹配，请按照“多装一卸”运输类型填写对应的装卸货信息',
							icon: 'none',
							 duration: 3000
						})
						return
					}
					this.yslxobj.label = this.yslxlist[index].packingSpec
					this.yslxobj.value = this.yslxlist[index].value
					this.zhshow = true
					this.shshow = false
				} else if (this.yslxlist[index].value == '4') {
					this.yslxobj.label = this.yslxlist[index].packingSpec
					this.yslxobj.value = this.yslxlist[index].value
					// console.log(555)
					this.zhshow = true
					this.shshow = true
				}


				// 	const index = e.detail.value;
				// 	const hw_ggList = this.yslxlist[eindex];
				// 	if (hw_ggList.length) {
				// 		this.$set(this.yslxlist, eindex, hw_ggList[index].packingSpec)
				// }		
			},
			// 所属合同
			hwtyhtChange(index, e, inx,type) {
				if(type == 1){
					let indexs = e.detail.value
					// console.log(this.hwinfohz[inx].ty_map.hwtyht[indexs],'合同',indexs)
					
					this.hwinfohz[inx].ty_map.ty_ssht = this.hwinfohz[inx].ty_map.hwtyht[indexs].packingSpec
					this.hwinfohz[inx].ty_map.ty_sshtid = this.hwinfohz[inx].ty_map.hwtyht[indexs].value
				}else if(type == 2){
						let indexs = e.detail.value
				// console.log(this.hwinfohz,'合同复制',indexs)
					this.hwinfohz[inx].ty_map.hwtyht.forEach((item,i)=>{
						if(item.value == this.hwinfohz[inx].ty_map.ty_sshtid){
							// console.log(item,'赋值2')
							this.hwinfohz[inx].ty_map.ty_ssht = item.packingSpec
						}
					})
						// console.log(this.hwinfohz[inx].ty_map.ty_ssht,'赋值')
				}
				// this.hwinfohz[inx].ty_map.ty_ssht
				
				// console.log(this.hwinfohz,88)
			},
			//货物信息-名称list
			hwNameListChange(res) {
				// console.log(res,666);

				let item = res.item;
				let index = res.data;
				let inx = res.item.inx
				if (!item.cateother) {
					this.getGoodsInfo(item.goodsId, item.inx).then(goodsInfo => {
						res.item = goodsInfo;
						this.hwNameListChange(res)
					}).catch(err => {
						console.log(err);
					})
					return;
				}
				
				// let arrsz = []
				// this.hwinfohz[inx].hw_map.ownerGoodsAlias.forEach((el, i) => {
				
				// 	arrsz.push(el)
				

				// })
				// let n = arrsz.indexOf(item.transportName)

				// console.log(n, 9);
				// if (n == -1) {
                   
					this.$set(this.hwinfohz[inx].hw_map.ownerGoodsName, index, item.certificatePrintingName)
					this.$set(this.hwinfohz[inx].hw_map.hw_type, index, item.cateother)
					this.$set(this.hwinfohz[inx].hw_map.category, index, item.category)
					this.$set(this.hwinfohz[inx].hw_map.termOther, index, item.termOther)
					this.$set(this.hwinfohz[inx].hw_map.ownerGoodsId, index, item.useDgoodsId)
					this.$set(this.hwinfohz[inx].hw_map.unCode, index, item.unNo)
					this.$set(this.hwinfohz[inx].hw_map.ownerGoodsAlias, index, item.transportName)
					
					//包装规格
					if (item.list.length) {
						var gg = item.list[0]
						this.$set(this.hwinfohz[inx].hw_map.hw_ggList, index, item.list)
						this.$set(this.hwinfohz[inx].hw_map.hw_gg, index, gg.packingSpec)
						this.$set(this.hwinfohz[inx].hw_map.hw_category, index, gg.packCategory)
						this.isbzgg = false
						// console.log(this.hw_map.hw_ggList[index],'数组11111');
						// console.log(this.hw_map.hw_category,'状态11111');
						// console.log(this.hw_map.hw_gg,'状态222');
					} else {
						this.isbzgg = true
						this.$set(this.hwinfohz[inx].hw_map.hw_ggList, index, [])
						this.$set(this.hwinfohz[inx].hw_map.hw_gg, index, "")
						this.$set(this.hwinfohz[inx].hw_map.hw_category, index, "")
					}
					this.xhhwlb(1)
					this.xhhwsj()
					// n = 0

				// } else {
				// 	uni.showToast({
				// 		title: '同一装货信息中不能选择相同货物',
				// 		icon: 'none',
				// 		// duration: 3000
				// 	})
				// }


			},
			//运输信息-押运人员
			yyyPersonChange(res) {
				const items = res.item;
				this.ysMsgMap.escortName = items.fullName;
				this.ysMsgMap.escortIdNumber = items.idNumber;
				this.ysMsgMap.escortEmpInfoId = items.empInfoId;
				this.ysMsgMap.escortTel = items.mobilePhone;
			},
			//运输信息-驾驶人员
			jsyPersonChange(res) {
				const items = res.item;
				this.ysMsgMap.driverName = items.fullName;
				this.ysMsgMap.driverEmpInfoId = items.empInfoId;
				this.ysMsgMap.driverIdNumber = items.idNumber;
				this.ysMsgMap.driverTel = items.mobilePhone;
			},
			//运输信息-车牌号
			vehCodeChange(res) {
				let item = res.item;
				this.ysMsgMap.vehCode = item.vehCode
				//1、改变车牌号 要更换ysMsgMap里面的信息
				this.ysMsgMap.vehCode = item.vehCode
				this.ysMsgMap.vehId = item.vehId
				this.ysMsgMap.trailerVehCode = item.trailerVehCode
				this.ysMsgMap.trailerVehId = item.trailerVehId
				this.ysMsgMap.mgrArea = item.mgrArea
				this.ysMsgMap.vehColor = item.vehColor
				//2、车牌号变了 货物信息要清空数据
				// this.clearHw();
				// this.addHw();
				//3、获取驾驶员、押运员的信息
				this.getJsyPerson();
				this.getYyyPerson();
			},
			//运输信息-挂车牌号
			gvehCodeChange(res) {
				let item = res.item;
				this.ysMsgMap.trailerVehCode = item.vehCode
				this.ysMsgMap.trailerVehId = item.vehId
			},
			//获取驾驶员信息
			getJsyPerson() {
				this.$api.JYPerson({
					'vehId': this.ysMsgMap.vehId,
					'personnelType': "1"
				}).then(res => {
					if (res.data.code == 200) {
						var listdata = res.data.data;
						if (listdata.length > 0) {
							this.jsyPerson.fullName = listdata[0].fullName;
							this.jsyPerson.empInfoId = listdata[0].empInfoId;
							this.jsyPerson.mobilePhone = listdata[0].mobilePhone;
						} else {
							this.jsyPerson.fullName = "";
							this.jsyPerson.empInfoId = "";
							this.jsyPerson.mobilePhone = "";
						}
					}
				}).catch(res => {

				});
			},
			//获取押运员信息
			getYyyPerson() {
				this.$api.JYPerson({
					'vehId': this.ysMsgMap.vehId,
					'personnelType': "2"
				}).then(res => {
					if (res.data.code == 200) {
						var listdata = res.data.data;
						if (listdata.length > 0) {
							this.yyyPerson.fullName = listdata[0].fullName;
							this.yyyPerson.empInfoId = listdata[0].empInfoId;
							this.yyyPerson.mobilePhone = listdata[0].mobilePhone;
						} else {
							this.yyyPerson.fullName = "";
							this.yyyPerson.empInfoId = "";
							this.yyyPerson.mobilePhone = "";
						}
					}
				}).catch(res => {});
			},
			// 获取途径省份信息
			getsfcode(){
				let dqcode = []
				 this.hwinfohz.forEach((ele,i)=>{
					 // console.log(ele,3402) //zh_map. zh_dqCode
					dqcode.push(ele.zh_map.zh_dqCode[0].substring(0, 2)+'0000') 
				 })
				 // element.substring(0, 2)
				 
				 this.xhinfohz.forEach((ele,i)=>{
				 		// console.log(ele,3403)  //sh_map.sh_dqCode
						 
						 dqcode.push(ele.sh_map.sh_dqCode[0].substring(0, 2)+'0000')
				 })
				  this.way_map.valuexl = dqcode.filter((item, index) => dqcode.indexOf(item) === index);
				  let a = this.getSelectPath(this.hwinfohz[0].zh_map.zh_dqCode[0])
				  let b =this.getSelectPath(this.xhinfohz[this.xhinfohz.length-1].sh_map.sh_dqCode[0])
				  this.way_map.route =this.getAreaCode(a)+'--'+this.getAreaCode(b)
				// way_map.valuexl
			},
			//单位
			dwChange(eindex, e) {
				const index = e.detail.value;
				// this.hw_map.hw_dw[eindex] = this.select.dw[index].text;
				this.$set(this.hw_map.hw_dw, eindex, this.select.dw[index].text)
					this.xhhwlb(1)
			},
			reasonChange(eindex, e) {
				const index = e.detail.value;
				// this.hw_map.hw_gg[eindex] = this.select.reason[index].text;
				this.$set(this.hw_map.hw_gg, eindex, this.select.reason[index].text)
			},
			//------------------------
			//是否同城
			isCityClick() {
				this.isCity = !this.isCity;
				if (this.isCity) {
					this.isWeiF = false
				}
				// if (this.zh_map.zh_name.length > 1) {
				// 	this.clearZh()
				// 	this.addZh()
				// }
			},
			//是否医废
			isWeiFClick() {
				this.isWeiF = !this.isWeiF;
				if (this.isWeiF) {
					this.isCity = false
				}
				// if (this.sh_map.sh_name.length > 1) {
				// 	this.clearSh()
				// 	this.addSh()
				// }
			},
			//------------------------
			//运输信息 车牌号
			cph() {
				this.$api.YsVechCode({
					'idNumber': this.$store.getters.getEmpIdCard,
				}).then(res => {
					if (res.data.data && res.data.data.length) {
						//父组件调用子组件方法
						this.$refs.child1.showBox({
							title: "请选择车牌号",
							getData: res.data.data.map(item => {
								item.$label = item.vehCode;
								return item;
							}),
						});
					} else {
						uni.showToast({
							title: '暂无数据!',
							icon: 'none'
						})
					}
				}).catch(res => {});
			},
			//运输信息 挂车牌号
			gcph() {
				this.$api.YsGVechCode({
					'vehCode': "",
				}).then(res => {
					if (res.data.data && res.data.data.length) {
						this.$refs.child2.showBox({
							title: "请选择挂车牌号",
							getData: res.data.data.map(item => {
								item.$label = item.vehCode;
								return item;
							}),
						});
					} else {
						uni.showToast({
							title: '暂无数据'
						});
					}
				}).catch(res => {});
			},
			//运输信息 驾驶员
			jsy() {
				this.$api.JYPerson({
					'vehId': this.ysMsgMap.vehId + '123',
					'personnelType': "1"
				}).then(res => {
					if (res.data.data && res.data.data.length) {
						this.$refs.child3.showBox({
							title: "请选择驾驶员",
							getData: res.data.data.map(item => {
								item.$label = item.fullName + (item.idNumber && "(" + item.idNumber
									.slice(-6) + ')')
								return item;
							})
						});
					} else {
						uni.showToast({
							title: '暂无数据',
							icon: 'none'
						})
					}
				}).catch(res => {});
			},
			//运输信息 押运员
			yyy() {
				this.$api.JYPerson({
					'vehId': this.ysMsgMap.vehId + '123',
					'personnelType': "2"
				}).then(res => {
					if (res.data.data && res.data.data.length) {
						this.$refs.child4.showBox({
							title: "请选择押运员",
							getData: res.data.data.map(item => {
								item.$label = item.fullName + (item.idNumber && "(" + item.idNumber
									.slice(-6) + ')')
								return item;
							})
						});
					} else {
						uni.showToast({
							title: '暂无数据',
							icon: 'none'
						})
					}
				}).catch(res => {});
			},
			//------------------------
			hwmc(index, key = "", inx) {
				if (this.vehGoodsName) {
					this.hwmc2(index, key, inx);
					// console.log(78787);
				} else {
					this.hwmc1(index, key, inx);
					// console.log(79797);
				}
			},
			//货物信息  货物名称
			hwmc1(index, key = "", inx) {
				//父组件调用子组件方法
				this.$refs.goodsName1.showBox({
					title: "请选择货物名称",
					data: index,
					key,

					getData: (key) => {
						return new Promise((resolve) => {
							this.$api.getGoodsName({
								'goodsName': key
							}).then(res => {
								const list = res.data.data.map((item) => {
									item.$label = item.unNo + ":" + item.transportName;
									var cate = item.category == "" ? "" : item
										.category +
										"类";
									var other = item.termOther == "" ? "" : item
										.termOther +
										"项";
									item.cateother = cate + other;
									item.inx = inx
									return item;
								});
								resolve(list);
							}).catch(res => {});
						})
					}
				});
			},
			hwmc2(index, key = "", inx) {
				//父组件调用子组件方法
				let vehId = this.ysMsgMap.vehId;
				this.$refs.goodsName2.showBox({
					title: "请选择货物名称",
					data: index,
					key,
					getData: (key, current) => {
						return new Promise((resolve) => {
							this.$api.getVehGoodsName({
								current,
								size: 20,
								vehId,
								goodsAlias: key
							}).then(res => {
								const resData = res.data.data;
								resData.records.forEach(item => {
									item.$label = item.dgoodsId + ":" + item
										.goodsAlias;
									item.inx = inx
								})
								resolve(resData);
							}).catch(res => {});
						})
					}
				});
			},
			getGoodsInfo(goodsId, inx) {
				return new Promise((resolve, reject) => {
					this.$api.getGoodsName({
						useDgoodsId: goodsId,
					}).then(res => {
						if (!res.data.data || res.data.data.length == 0) {
							// this.showToast('获取货物信息失败');
							reject('没有查询到数据');
							return false;
						}
						let item = res.data.data[0];

						// 取得项别类别
						item.cateother = "";
						if (item.category) {
							item.cateother += item.category + '类'
						}
						if (item.termOther) {
							item.cateother += item.termOther + '项'
						}
						item.inx = inx
						resolve(item);
					}).catch(res => {
						this.showToast('获取货物信息失败');
						reject(res);
					});
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		padding: 20rpx;


		.add-btns {
			text-align: center;
			padding: 20rpx 0;

			.btn-cancel,
			.btn-submit {

				display: inline-block;
				margin: 0 30rpx;
				border-radius: 50rpx;
				padding: 0 80rpx;
				font-size: 32rpx;
			}

			.btn-cancel {
				border: 2rpx solid #CCCCCC;
				line-height: 70rpx;
			}

			.btn-submit {
				line-height: 70rpx;
				background-color: $app-color;
			}
		}



		.isPadding {
			padding-bottom: 20rpx;
		}


		//装货
		.zh_msg {
			background-color: #FFFFFF;
			border-radius: 20rpx;
			margin-top: 20rpx;

		}

		// 货物信息
		.hw_msg {
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding-bottom: 20rpx;
			margin-top: 20rpx;


		}

		.item_top {
			display: flex;
			height: 100rpx;
			flex-direction: column;

			.view_pai {
				border-left: 5rpx solid $app-color;
				padding-left: 20rpx;
				padding-right: 20rpx;
				height: 30rpx;
				// background-color: #07C160;
				margin-top: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.text_pai {
					font-size: 28rpx;
					font-weight: 700;
				}

				.delect {
					width: 30rpx;
					height: 30rpx;
				}
			}

			.line {
				height: 2rpx;
				margin: 30rpx 20rpx 0rpx 20rpx;
				background-color: #F2F2F2;
			}

		}

		//+新增运输货物样式
		.hw_btn {
			height: 60rpx;
			margin: 20rpx 20rpx 0rpx 20rpx;
			border: 1px dashed #A4A4A4;
			display: flex;
			align-items: center;
			justify-content: center;

			text {
				color: #A4A4A4;
			}
		}

		//是否同城 是否医废危废
		.tcwf {
			margin-top: 20rpx;
			display: flex;
			height: 40rpx;
			align-items: center;
		}

		.info-item {
			display: flex;
			margin: 0rpx 20rpx;
			padding: 20rpx 0;
			border-bottom: 2rpx solid #F2F2F2;
			align-items: flex-start;


			.text {
				font-size: 28rpx;
				line-height: 36rpx;
			}

			.input {
				font-size: 28rpx;
				height: 36rpx;
				line-height: 36rpx;
				flex: 1;
				padding: 0 20rpx;
			}

			.inputDq {
				font-size: 28rpx;
				height: 36rpx;
				line-height: 36rpx;
				flex: 1;
				padding: 0 20rpx;
			}

			.text_dw {
				color: $app-color;
			}


			.date-select {
				flex: 1;

				::v-deep .uni-date-x--border {
					border: 0;

					.uni-date-x {
						padding: 0 10rpx;
					}

					.uni-icons {
						display: none;
					}

					.uni-date__x-input {
						line-height: 36rpx;
						height: 36rpx;
					}

					.uni-input-input {
						font-size: 28rpx;
					}
				}
			}
		}

		// 运输信息
		.ys_msg {
			background-color: #FFFFFF;
			border-radius: 20rpx;

			.item_top {
				display: flex;
				height: 100rpx;
				flex-direction: column;

				.view_pai {
					border-left: 5rpx solid $app-color;
					padding-left: 20rpx;
					height: 40rpx;
					// background-color: #07C160;
					margin-top: 30rpx;

					.text_pai {
						font-size: 28rpx;
						font-weight: 700;
					}
				}

				.line {
					height: 2rpx;
					margin: 30rpx 20rpx 0rpx 20rpx;
					background-color: #F2F2F2;
				}

			}

			.ys_item {
				height: 100rpx;
				display: flex;
				align-items: center;
				margin: 0rpx 20rpx;
				border-bottom: 2rpx solid #F2F2F2;

				.text_item {
					display: flex;

					.lable {
						color: $app-color;
					}

					.value {
						margin-left: 20rpx;
					}

					&[span="2"] {
						width: 50%;
					}

				}
			}
		}
	}

	.tip-text {
		color: #888;
		padding-left: 20rpx;
	}

	.zhinfo {
		height: 82rpx;
		line-height: 83rpx;
		background-color: #fffbe6;

		padding-left: 20rpx;
	}

	.shinfo {
		height: 82rpx;
		line-height: 83rpx;
		// background-color: #ffeedd;
		background-color: #fffbe6;

		padding-left: 20rpx;
	}
</style>
